-
-
Notifications
You must be signed in to change notification settings - Fork 454
Description
###Configuration:
PhpFastCache version: 5.0.15
PHP version: 7.0.16
Operating system: Centos 6.8
####Issue description:
I can't figure out how to set a host/port for Memcached using phpFastCache and the example file doesn't state how to do so. I've tried using setDefaultConfig and the second getInstance parameter without success. With just memcached, this is simple enough;
$cache = new memcached();
$cache->addServer("127.0.0.1", 3333);
It works and sets/gets properly.
How do I achieve the same result with phpFastCache? I've tried the following;
$InstanceCache = CacheManager::getInstance("memcached", ['host' => "127.0.0.1",'port' => 3333]);
$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("Memcached Cache --> Cache Enabled --> Well done !")->expiresAfter(120);
$InstanceCache->save($CachedString);
echo "FIRST LOAD // WROTE OBJECT TO CACHE // RELOAD THE PAGE AND SEE // ";
echo $CachedString->get();
} else {
echo "READ FROM CACHE // ";
echo $CachedString->get();
}
But I never to get "Read from cache", indicating that phpFastCache isn't saving properly.