* @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) <*****@*****.**> * */ // 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();
* @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) <*****@*****.**> * */ // 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 // ";
* @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) <*****@*****.**> * */ // 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 // ";
/** * */ private function initCache() { \phpFastCache\CacheManager::setDefaultConfig(array('path' => JigoshopInit::getLogDir())); }