时间:2021-07-01 10:21:17 帮助过:45人阅读
for php pecl-memcached, because it’s using libmemcache, so no this issue.
We write a function to choose which memcache extension we will use in our code:
$mem_flag = 0;$mem_conn = null;function mcached_conn(){ global $config, $mem_flag, $mem_conn; if($mem_flag != 1) { if ($config['mcache']['version']==0){ $mem_conn = memcache_pconnect($config['mcache']['host'], 11211); } else { $mem_conn = new Memcached(); $mem_conn->addServer($config['mcache']['host'], 11211); } $mem_flag = 1; } return $mem_conn;}function memcache_version_set($memcache_obj, $key,$value,$flag,$ttl){ global $config; if ($config['mcache']['version']==0){ return memcache_set($memcache_obj, $key,$value,$flag,$ttl); } else { return $memcache_obj->set($key,$value,$ttl); }} function memcache_version_get($memcache_obj, $key){ global $config; if ($config['mcache']['version']==0){ return memcache_get($memcache_obj, $key); } else { return $memcache_obj->get($key); }}function memcache_version_del($memcache_obj, $key){ global $config; if ($config['mcache']['version']==0){ return memcache_delete($memcache_obj, $key); } else { return $memcache_obj->delete($key); }}?