THINKPHP 自带memcache 扩展.
这个是配置信息,写到config里面去就行了.
$options = array (
'timeout' = C('DATA_CACHE_TIMEOUT') ? C('DATA_CACHE_TIMEOUT') : false,
'persistent' = false,
'expire' =C('DATA_CACHE_TIME'),
'length' =0,
);
单击开始菜单,运行"cmd".
cd .. //进入c盘
cd memcached //进入memcache目录
memcache.exe -d install //安装memcache服务
设置php:找到php安装目录,打开php.ini文件.找到配置文件里允许支持扩展的区域exetension=..,添加一行exetension=php_memcache.dll.
设置apache:
打开apache配置文件httpd.conf,找到LoadModule加载模块区域.去掉前面的"LoadModule mem_cache_module modules/mod_mem_cache.so"#号
重启apache服务.linux下重启使用命令:service httpd restart.
然后就大功告成!
用mac 做开发环境,封装 Cache,在没用 memcache 扩展的时候,使用 Cache 的时候,使用 file 替代.再生产环境的时候,如果有装 memcache 会自动切换.
class TL_Cache
{
private $_file;
private $_mem;
function __construct($key)
//$ever = 'var'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.'.ever';
$ever = 'var'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.'data';
$this-_mem = TL_Mem::getInstance();
}
public function get()
$res = TL_FSO::getFileContent($this-_file);
return unserialize($res);;
//error_log('get from cache');
return null;
public function set($val)
$val = serialize($val);
return TL_FSO::createFile($this-_file, $val);
public function delete()
TL_FSO::deleteFile($this-_file);
public function getVal($key)
return $this-get();
public function setVal($key, $val)
return $this-set($val);
看样子应该有 memchached 的一个封装类,这个文件你没引用吧
$mem = new memcached;
这样的用法你要在前面加封装类的引用,(include "init.php" 类似的)具体类定义文件你找找相关文件吧.
[raykaeso@web ~]$ wget
Configuring for:
注意:一定要用root用户.
extension=memcache.so
memcache
memcache Support enabled
Linux下php安装memcache扩展 -
以上就是土嘎嘎小编为大家整理的phpmemcache封装的简单介绍phpmemcache封装的简单介绍相关咨询咨询主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!