我目前能够使用Memcached类正确使用Memcached。设置Memcached的端口似乎是这样的;
$mem = new memcached();
$mem->addServer("127.0.0.1", 3333);
memcached类正确连接到memcached服务器,并且能够设置/获取。
但是对于phpFastCache,我似乎无法正确设置端口号,其文档也没有提供大量示例。但它似乎有一个主机/端口设置;
https://gist.github.com/Geolim4/69471ccd398f2a919f109063ecc0c971#file-setup-and-options-md
我认为设置它的正确方法就是这样;
$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();
}
但是代码永远不会出现“READ FROM CACHE”。我应该在其他地方设置主机/端口吗?