2018-02-02

PHP7 Memcached CAS 变化

服务器升级PHP7后发现一些Memcached的get和getMulti方法的Warning,查阅了一下官方文档,原来PHP7中Memcached扩展的CAS实现有所变化:

As of some version of php7 (i was not able to determine which exactly).
The $cas_token is no longer valid argument. It has been removed in favor of flags argument, as it appears to be causing issues when subclassing the Memcached class.

See https://github.com/php-memcached-dev/php-memcached/pull/214 for more details.

Basically you need to 
get($key, $cb, Memcached::GET_EXTENDED);
    $o = $_o['value'];
    $cas = $_o['cas'];
  } else {
    $o = $m->get($key, $cb, $cas);
  }
  return $o;
}
?>

PHP7中用Memcached::GET_EXTENDED参数表示获取cas,token不再以引用方式获取而是直接返回,getMulti也是一样。

你可能感兴趣的:(2018-02-02)