doudieyou5209 2017-03-22 00:22
浏览 52
已采纳

在PHPFastCache中设置memcached主机/端口

I'm currently able to use Memcached proper using the Memcached class. Setting the port for Memcached seems to work like this;

$mem = new memcached();

$mem->addServer("127.0.0.1", 3333);

The memcached class connects properly to the memcached server and is able to set/get.

For phpFastCache however, I can't seem to set the port number properly and its documentation doesn't offer a whole lot of examples. It does however seem to have a setting for hosts/ports;

https://gist.github.com/Geolim4/69471ccd398f2a919f109063ecc0c971#file-setup-and-options-md

I would assume the proper way to set it would be like this;

$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 the code never gets to "READ FROM CACHE". Am I supposed to set up the host/port somewhere else?

  • 写回答

1条回答 默认 最新

  • dongtang6775 2017-03-25 19:31
    关注

    Are you the author of this issue ? If not, I suggest you to have a look at it.

    Cheers, Georges

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口