/** * Return the object instance (Singleton) * * @return \Session The object instance */ public static function getInstance() { if (static::$objInstance === null) { static::$objInstance = CacheManager::getInstance(static::$driver, self::getOptions()); } return static::$objInstance; }
/** * Create and return the instance of phpFastCache\CacheManager * * @return object the instance of the Cache Manager if cache enabled * in the configuration file (config/cache.php), null * if disabled * * @static * @see Cache::clean() * @access public * @since Method available since Release 0.1.0 */ static function init() { if (self::$config === null) { self::$config = Config::get('cache'); } if (self::$config['enabled'] === true) { CacheManager::setup(self::$config['settings']); if (self::$CacheManager === null) { self::$CacheManager = CacheManager::getInstance(); } return self::$CacheManager; } else { return null; } }
/** * @param string $storage * @param array $config * @return DriverAbstract */ public static function getInstance($storage = 'auto', $config = array()) { return parent::getInstance($storage, self::getOptions()); }
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('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 {
/** * * 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('xcache'); /** * 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("Xcache 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 // ";
public function __construct(ProductServiceInterface $service) { $this->service = $service; $this->instanceCache = CacheManager::getInstance('files'); }
* 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 {
/** * 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(); }
* @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 // ";
/** * * 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 // ";
/** * * 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('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 // ";
* 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 {
/** * * 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
/** * * 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 // ";
} 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,
/** * 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 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 {
* 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 {
/** * 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" => '/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);
/** * 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); }