public static function getOptions() { $arrOptions = array(); $arrOptions['storage'] = static::$driver; $arrOptions = static::extendOptions($arrOptions); $arrOptions = array_merge(CacheManager::getDefaultConfig(), $arrOptions); return $arrOptions; }
public function __construct($customerKey, $environmentKey, $options = array()) { $this->_customerKey = $customerKey; $this->_environmentKey = $environmentKey; $this->_auth = "{$customerKey}:{$environmentKey}"; $this->_api = 'https://api.featureswitches.com/v1/'; if (isset($options['api'])) { $this->_api = $options['api']; } $this->_cacheTimeout = 300; if (isset($options['cache_timeout'])) { $this->_cacheTimeout = $options['cache_timeout']; } CacheManager::setup(array("path" => sys_get_temp_dir())); CacheManager::CachingMethod("phpfastcache"); $this->_cache = CacheManager::Files(); $this->_httpClient = new Client(array('base_uri' => $this->_api)); }
/** * * This file is part of phpFastCache. * * @license MIT License (MIT) * * For full copyright and license information, please see the docs/CREDITS.txt file. * * @author Khoa Bui (khoaofgod) <*****@*****.**> http://www.phpfastcache.com * @author Georges.L (Geolim4) <*****@*****.**> * */ use phpFastCache\CacheManager; // Include composer autoloader require __DIR__ . '/../vendor/autoload.php'; $InstanceCache = CacheManager::getInstance('mongodb', ['host' => '127.0.0.1', 'port' => '27017', 'username' => '', 'password' => '', 'timeout' => '1']); /** * Try to get $products from Caching First * product_page is "identity keyword"; */ $key = "product_page"; $CachedString = $InstanceCache->getItem($key); /* var_dump($CachedString->get()); exit; */ if (is_null($CachedString->get())) { // Write products to Cache in 10 minutes with same keyword $CachedString->set("Mongodb Cache --> Cache Enabled --> Well done !")->expiresAfter(5); $InstanceCache->save($CachedString); echo "FIRST LOAD // WROTE OBJECT TO CACHE // RELOAD THE PAGE AND SEE // "; echo $CachedString->get(); } else {
* For full copyright and license information, please see the docs/CREDITS.txt file. * * @author Khoa Bui (khoaofgod) <*****@*****.**> http://www.phpfastcache.com * @author Georges.L (Geolim4) <*****@*****.**> * */ // Include composer autoloader require __DIR__ . '/../vendor/autoload.php'; // OR require_once("../src/phpFastCache/phpFastCache.php"); date_default_timezone_set("Europe/Paris"); use phpFastCache\CacheManager; use phpFastCache\Core\phpFastCache; // Setup File Path on your config files CacheManager::setDefaultConfig(["path" => sys_get_temp_dir()]); // In your class, function, you can call the Cache $InstanceCache = CacheManager::getInstance('leveldb'); // OR $InstanceCache = CacheManager::getInstance() <-- open examples/global.setup.php to see more /** * Try to get $products from Caching First * product_page is "identity keyword"; */ $key = "product_page"; $CachedString = $InstanceCache->getItem($key); if (is_null($CachedString->get())) { //$CachedString = "Files Cache --> Cache Enabled --> Well done !"; // Write products to Cache in 10 minutes with same keyword $CachedString->set("Files Cache --> Cache Enabled --> Well done !")->expiresAfter(5); $InstanceCache->save($CachedString); echo "FIRST LOAD // WROTE OBJECT TO CACHE // RELOAD THE PAGE AND SEE // "; echo $CachedString->get(); } else {
/** * apc缓存 * * @param array $config 配置参数 * @return \phpFastCache\Core\DriverAbstract */ private function apc() { $InstanceCache = CacheManager::getInstance('apc'); return $InstanceCache; }
* For full copyright and license information, please see the docs/CREDITS.txt file. * * @author Khoa Bui (khoaofgod) <*****@*****.**> http://www.phpfastcache.com * @author Georges.L (Geolim4) <*****@*****.**> * */ // Include composer autoloader require __DIR__ . '/../vendor/autoload.php'; // OR require_once("../src/phpFastCache/phpFastCache.php"); date_default_timezone_set("Europe/Paris"); use phpFastCache\CacheManager; use phpFastCache\Core\phpFastCache; // Setup File Path on your config files CacheManager::setDefaultConfig(["path" => sys_get_temp_dir(), "itemDetailedDate" => true]); // In your class, function, you can call the Cache $InstanceCache = CacheManager::getInstance('files'); // OR $InstanceCache = CacheManager::getInstance() <-- open examples/global.setup.php to see more /** * Try to get $products from Caching First * product_page is "identity keyword"; */ $key = "product_page"; $CachedString = $InstanceCache->getItem($key); if (is_null($CachedString->get())) { //$CachedString = "Files Cache --> Cache Enabled --> Well done !"; // Write products to Cache in 10 minutes with same keyword $CachedString->set("Files Cache --> Cache Enabled --> Well done !")->expiresAfter(60); $InstanceCache->save($CachedString); echo "FIRST LOAD // WROTE OBJECT TO CACHE // RELOAD THE PAGE AND SEE // "; echo $CachedString->get(); } else {
* For full copyright and license information, please see the docs/CREDITS.txt file. * * @author Khoa Bui (khoaofgod) <*****@*****.**> http://www.phpfastcache.com * @author Georges.L (Geolim4) <*****@*****.**> * */ // Include composer autoloader require __DIR__ . '/../vendor/autoload.php'; // OR require_once("../src/phpFastCache/phpFastCache.php"); date_default_timezone_set("Europe/Paris"); use phpFastCache\CacheManager; use phpFastCache\Core\phpFastCache; // Setup File Path on your config files CacheManager::setDefaultConfig(["path" => '/var/www/phpfastcache.dev.geolim4.com/geolim4/tmp']); // In your class, function, you can call the Cache $InstanceCache = CacheManager::getInstance('redis'); /** * Try to get $products from Caching First * product_page is "identity keyword"; */ $key = "product_decrement"; $CachedString = $InstanceCache->getItem($key); if (is_null($CachedString->get())) { $CachedString->set(1000)->expiresAfter(10); echo "FIRST LOAD // WROTE OBJECT TO CACHE // RELOAD THE PAGE AND SEE // DECREMENT // "; echo $CachedString->decrement()->get(); } else { echo "READ FROM CACHE // decrement // "; echo $CachedString->decrement()->get(); } $InstanceCache->save($CachedString);
/** * Check the table information cache for the given table data * * @param string $database * @param string $table * @return string */ public function tableInfo($database, $table) { // use the mysql registry for this request to look up information about the database/table on this host $tableInfo = MysqlTableInfo::getInfo($this->hosts['master'], $database, $table); $MemcacheConn = null; if ($tableInfo) { return $tableInfo; } $key = current($this->hosts['master']) . "|{$database}.{$table}"; $isLocal = ServerUtility::isLocal(); // Using file cache to make thie more portable need to expose caching layer in the future CacheManager::setup(array("path" => sys_get_temp_dir())); $InstanceCache = CacheManager::Files(); // when running a local machine we want to allow schema updates to happen at anytime so no caching layer in place if ($isLocal) { $tableInfo = false; } else { $tableInfo = $InstanceCache->get($key); } if (!$tableInfo) { $tableInfo = $this->generateSchemaJson($database, $table); $InstanceCache->set($key, $tableInfo, $this->tableInfoCacheSec); MysqlTableInfo::setInfo($this->hosts['master'], $database, $table, $tableInfo); } return $tableInfo; }
/** * phpFastCache constructor. * @param string $driver * @param array $config */ public function __construct($driver = 'auto', array $config = []) { $this->instance = CacheManager::getInstance($driver, $config); }
* @license MIT License (MIT) * * For full copyright and license information, please see the docs/CREDITS.txt file. * * @author Khoa Bui (khoaofgod) <*****@*****.**> http://www.phpfastcache.com * @author Georges.L (Geolim4) <*****@*****.**> * */ use phpFastCache\CacheManager; // Include composer autoloader require __DIR__ . '/../vendor/autoload.php'; // OR without composer: // require __DIR__ . '/../src/autoload.php'; // require __DIR__ . 'YOUR_PROJECT/phpfastcache/phpssdb/src/autoload.php'; // require __DIR__ . 'YOUR_PROJECT/fig_cache_interfaces.php'; $InstanceCache = CacheManager::getInstance('ssdb'); /** * Try to get $products from Caching First * product_page is "identity keyword"; */ $key = "product_page"; $CachedString = $InstanceCache->getItem($key); if (is_null($CachedString->get())) { //$CachedString = "APC Cache --> Cache Enabled --> Well done !"; // Write products to Cache in 10 minutes with same keyword $CachedString->set("Ssdb Cache --> Cache Enabled --> Well done !")->expiresAfter(5); $InstanceCache->save($CachedString); echo "FIRST LOAD // WROTE OBJECT TO CACHE // RELOAD THE PAGE AND SEE // "; echo $CachedString->get(); } else { echo "READ FROM CACHE // ";
$rootpath = dirname($includepath); $base_theaters = array(); // Pull in configuration settings include "{$includepath}/config.php"; /* BEGIN COMMON EXECUTION CODE This section is run by every script, so it shouldn't do too much. */ // Load custom library paths for include //parseLibPath(); use phpFastCache\CacheManager; //require_once("phpfastcache/phpfastcache.php"); //phpFastCache::setup CacheManager::setup(array("path" => $cachepath, "allow_search" => true)); CacheManager::CachingMethod("phpfastcache"); $cache = CacheManager::Files(); //new phpFastCache("files"); //$cache->driver_set('path',$cachepath); //$cache->driver_set('securitykey','cache.folder'); // Connect to HLStatsX database if requested if (isset($use_hlstatsx_db)) { // If HLStatsX config exists, try that first if (file_exists($hlstatsx_config)) { require $hlstatsx_config; mysql_connect(DB_HOST, DB_USER, DB_PASS); $mysql_connection = mysql_select_db(DB_NAME); } // If no database connected (either config missing or failed to connect) use fallback if (@(!$mysql_connection)) { mysql_connect($mysql_server, $mysql_username, $mysql_password); $mysql_connection = mysql_select_db($mysql_database);
/** * * This file is part of phpFastCache. * * @license MIT License (MIT) * * For full copyright and license information, please see the docs/CREDITS.txt file. * * @author Lucas Brucksch <*****@*****.**> * */ use phpFastCache\CacheManager; // Include composer autoloader require __DIR__ . '/../vendor/autoload.php'; $InstanceCache = CacheManager::getInstance('zendshm'); /** * Try to get $products from Caching First * product_page is "identity keyword"; */ $key = "product_page"; $CachedString = $InstanceCache->getItem($key); if (is_null($CachedString->get())) { //$CachedString = "Zend Memory Cache --> Cache Enabled --> Well done !"; // Write products to Cache in 10 minutes with same keyword $CachedString->set("Zend Memory Cache --> Cache Enabled --> Well done !")->expiresAfter(5); $InstanceCache->save($CachedString); echo "FIRST LOAD // WROTE OBJECT TO CACHE // RELOAD THE PAGE AND SEE // "; echo $CachedString->get(); } else { echo "READ FROM CACHE // ";
/** * * This file is part of phpFastCache. * * @license MIT License (MIT) * * For full copyright and license information, please see the docs/CREDITS.txt file. * * @author Khoa Bui (khoaofgod) <*****@*****.**> http://www.phpfastcache.com * @author Georges.L (Geolim4) <*****@*****.**> * */ use phpFastCache\CacheManager; // Include composer autoloader require __DIR__ . '/../vendor/autoload.php'; $InstanceCache = CacheManager::getInstance('apc'); /** * Try to get $products from Caching First * product_page is "identity keyword"; */ $key = "product_page"; $key2 = "product_page2"; $CachedString = $InstanceCache->getItem($key); $CachedString2 = $InstanceCache->getItem($key2); if (is_null($CachedString->get()) || is_null($CachedString2->get())) { // Write products to Cache in 10 minutes with same keyword $CachedString->set("My beautifull Ios product")->expiresAfter(600)->addTag('Mobile')->addTag('Ios'); $CachedString2->set("My beautifull Android product")->expiresAfter(600)->addTag('Mobile')->addTag('Android'); $InstanceCache->save($CachedString); $InstanceCache->save($CachedString2); echo "FIRST LOAD // WROTE OBJECT TO CACHE // RELOAD THE PAGE AND SEE // ";
/** * Parser constructor. * @throws ParseException */ public function __construct() { $this->cache = new Cache(CacheManager::Files(), 'routerunner_cache'); }
/** * ActOnAll constructor. */ public function __construct() { $this->instances =& CacheManager::getInternalInstances(); }
/** * * This file is part of phpFastCache. * * @license MIT License (MIT) * * For full copyright and license information, please see the docs/CREDITS.txt file. * * @author Khoa Bui (khoaofgod) <*****@*****.**> http://www.phpfastcache.com * @author Georges.L (Geolim4) <*****@*****.**> * */ use phpFastCache\CacheManager; // Include composer autoloader require __DIR__ . '/../vendor/autoload.php'; $InstanceCache = CacheManager::getInstance('cookie'); /** * Try to get $products from Caching First * product_page is "identity keyword"; */ $key = "product_page"; $CachedString = $InstanceCache->getItem($key); if (is_null($CachedString->get())) { //$CachedString = "Cookie Cache --> Cache Enabled --> Well done !"; // Write products to Cache in 10 minutes with same keyword $CachedString->set("Cookie Cache --> Cache Enabled --> Well done !")->expiresAfter(5); $InstanceCache->save($CachedString); echo "FIRST LOAD // WROTE OBJECT TO CACHE // RELOAD THE PAGE AND SEE // "; echo $CachedString->get(); } else { echo "READ FROM CACHE // ";
function __c($storage = 'auto', $config = array()) { return CacheManager::getInstance($storage, $config); }
/** * * This file is part of phpFastCache. * * @license MIT License (MIT) * * For full copyright and license information, please see the docs/CREDITS.txt file. * * @author Khoa Bui (khoaofgod) <*****@*****.**> http://www.phpfastcache.com * @author Georges.L (Geolim4) <*****@*****.**> * */ use phpFastCache\CacheManager; // Include composer autoloader require __DIR__ . '/../vendor/autoload.php'; $InstanceCache = CacheManager::getInstance('couchbase', ['host' => 'your-couchbase-host', 'port' => '11211', 'username' => 'your-couchbase-username', 'password' => 'your-couchbase-password', 'timeout' => '1', 'buckets' => [['default' => 'Cache', 'password' => '']]]); /** * Try to get $products from Caching First * product_page is "identity keyword"; */ $key = "product_page"; $CachedString = $InstanceCache->getItem($key); if (is_null($CachedString->get())) { //$CachedString = "APC Cache --> Cache Enabled --> Well done !"; // Write products to Cache in 10 minutes with same keyword $CachedString->set("Couchbase Cache --> Cache Enabled --> Well done !")->expiresAfter(5); $InstanceCache->save($CachedString); echo "FIRST LOAD // WROTE OBJECT TO CACHE // RELOAD THE PAGE AND SEE // "; echo $CachedString->get(); } else { echo "READ FROM CACHE // ";
/** * @param string $storage * @param array $config * @return DriverAbstract */ public static function getInstance($storage = 'auto', $config = array()) { return parent::getInstance($storage, self::getOptions()); }
<?php /** * * This file is part of phpFastCache. * * @license MIT License (MIT) * * For full copyright and license information, please see the docs/CREDITS.txt file. * * @author Khoa Bui (khoaofgod) <*****@*****.**> http://www.phpfastcache.com * @author Georges.L (Geolim4) <*****@*****.**> * */ namespace phpFastCache\plugins; use phpFastCache\CacheManager; // Setup your cronjob to run this file every // 30 mins - 60 mins to help clean up // the expired files faster require_once __DIR__ . "/../phpFastCache.php"; $setup = array("path" => "/your_path/to_clean/"); $cache = CacheManager::Files($setup); // clean up expired files cache every hour // For now only "files" drivers is supported $cache->autoCleanExpired(3600 * 1);
/** * * This file is part of phpFastCache. * * @license MIT License (MIT) * * For full copyright and license information, please see the docs/CREDITS.txt file. * * @author Khoa Bui (khoaofgod) <*****@*****.**> http://www.phpfastcache.com * @author Georges.L (Geolim4) <*****@*****.**> * */ use phpFastCache\CacheManager; // Include composer autoloader require __DIR__ . '/../vendor/autoload.php'; $InstanceCache = CacheManager::getInstance('memcached'); /** * In case you need SASL authentication: * $InstanceCache = CacheManager::getInstance('memcache', ['sasl_user' => 'hackerman', 'sasl_password' => '12345']); * Warning: Memcache needs to be compiled with a specific option (--enable-memcached-sasl) to use sasl authentication, see: * http://php.net/manual/fr/memcached.installation.php */ /** * Try to get $products from Caching First * product_page is "identity keyword"; */ $key = "product_page"; $CachedString = $InstanceCache->getItem($key); if (is_null($CachedString->get())) { //$CachedString = "APC Cache --> Cache Enabled --> Well done !"; // Write products to Cache in 10 minutes with same keyword
/** * CacheItemPool constructor. * * @param array $config * @param string $method */ public function __construct(array $config, $method = 'normal') { CacheManager::setup($config); CacheManager::CachingMethod($method); $this->_cache = CacheManager::getInstance(); }
* For full copyright and license information, please see the docs/CREDITS.txt file. * * @author Khoa Bui (khoaofgod) <*****@*****.**> http://www.phpfastcache.com * @author Georges.L (Geolim4) <*****@*****.**> * */ // Include composer autoloader require __DIR__ . '/../vendor/autoload.php'; // OR require_once("../src/phpFastCache/phpFastCache.php"); date_default_timezone_set("Europe/Paris"); use phpFastCache\CacheManager; use phpFastCache\Core\phpFastCache; // Setup File Path on your config files CacheManager::setDefaultConfig(["path" => sys_get_temp_dir()]); // In your class, function, you can call the Cache $InstanceCache = CacheManager::getInstance('sqlite'); // OR $InstanceCache = CacheManager::getInstance() <-- open examples/global.setup.php to see more /** * Try to get $products from Caching First * product_page is "identity keyword"; */ $key = "product_page"; $CachedString = $InstanceCache->getItem($key); if (is_null($CachedString->get())) { //$CachedString = "Files Cache --> Cache Enabled --> Well done !"; // Write products to Cache in 10 minutes with same keyword $CachedString->set("Files Cache --> Cache Enabled --> Well done !")->expiresAfter(5); $InstanceCache->save($CachedString); echo "FIRST LOAD // WROTE OBJECT TO CACHE // RELOAD THE PAGE AND SEE // "; echo $CachedString->get(); } else {
} catch (Exception $e) { $handler = new NativeFileSessionHandler(root . '/Private/Sessions'); } $storage = new NativeSessionStorage(['cookie_lifetime' => 86400, 'gc_maxlifetime' => 86400, 'cookie_httponly' => '1'], $handler); return new Session($storage); }, 'User' => function () { return new Apps\ActiveRecord\User(); }, 'Mailer' => function () { $swiftTransport = Swift_MailTransport::newInstance(); return Swift_Mailer::newInstance($swiftTransport); }, 'Captcha' => function () { return new Extend\Core\Captcha\Gregwar(); }, 'Cache' => function () { // initialize cache manager. You can use redis, memcache or anything else. Look at: phpfastcache.com CacheManager::setup(['storage' => 'files', 'path' => root . '/Private/Cache']); return CacheManager::getInstance('files'); }, '_hybridauth' => function () { /** Uncomment code below to enable social oauth $instance = new Hybrid_Auth([ 'base_url' => App::$Alias->scriptUrl . '/api/user/endpoint?lang=en', 'providers' => [ 'Twitter' => [ 'enabled' => true, 'keys' => [ 'key' => 'my_app_key', 'secret' => 'my_app_secret' ], 'scope' => 'email' ], 'Github' => [ 'enabled' => true,
public function __construct(ProductServiceInterface $service) { $this->service = $service; $this->instanceCache = CacheManager::getInstance('files'); }
/** * Clear all cached data * * @static * @access public * @since Method available since Release 0.1.0 */ static function clean() { CacheManager::clean(); }
* * @license MIT License (MIT) * * For full copyright and license information, please see the docs/CREDITS.txt file. * * @author Lucas Brucksch <*****@*****.**> * */ // Include composer autoloader require __DIR__ . '/../vendor/autoload.php'; // OR require_once("../src/phpFastCache/phpFastCache.php"); date_default_timezone_set("Europe/Paris"); use phpFastCache\CacheManager; use phpFastCache\Core\phpFastCache; // In your class, function, you can call the Cache $InstanceCache = CacheManager::getInstance('zenddisk'); // OR $InstanceCache = CacheManager::getInstance() <-- open examples/global.setup.php to see more /** * Try to get $products from Caching First * product_page is "identity keyword"; */ $key = "product_page"; $CachedString = $InstanceCache->getItem($key); if (is_null($CachedString->get())) { //$CachedString = "Zend Disk Cache --> Cache Enabled --> Well done !"; // Write products to Cache in 10 minutes with same keyword $CachedString->set("Zend Disk Cache --> Cache Enabled --> Well done !"); $InstanceCache->save($CachedString); echo "FIRST LOAD // WROTE OBJECT TO CACHE // RELOAD THE PAGE AND SEE // "; echo $CachedString->get(); } else {
$container['logger'] = function ($c) { $settings = $c->get('settings')['logger']; $logger = new Monolog\Logger($settings['name']); $logger->pushProcessor(new Monolog\Processor\UidProcessor()); $logger->pushHandler(new Monolog\Handler\RotatingFileHandler($settings['path'])); if (!empty($settings['token'])) { $logger->pushHandler(new Logentries\Handler\LogentriesHandler($settings['token'])); } return $logger; }; /** * Caching */ $container['cache'] = function ($c) { \phpFastCache\CacheManager::setup(["path" => $c->get('settings')['cache']['path']]); return \phpFastCache\CacheManager::Files(); }; /** * Middlewares */ require __DIR__ . '/middlewares.php'; /** * Routes */ require __DIR__ . '/routes.php'; /** * Fallback route */ require __DIR__ . '/fallback.php'; /** * Dispatch
/** * @return \phpFastCache\Core\DriverAbstract */ protected function _tagCaching() { return CacheManager::Sqlite(array("path" => $this->config['path'], "cache_method" => 3)); }
/** * phpFastCache constructor. * @param string $storage * @param array $config */ public function __construct($storage = '', $config = array()) { if (empty($config)) { $config = phpFastCache::$config; } $config['storage'] = $storage; $storage = strtolower($storage); if ($storage == '' || $storage == 'auto') { $storage = self::getAutoClass($config); } $this->instance = CacheManager::getInstance($storage, $config); }