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 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题