Thinkphp框架中使用memcache缓存的方法

http://blog.csdn.net/yl_wh/article/details/8538926

 

转载自:http://blog.163.com/qiuxinke2006@126/blog/static/24885580201201821632676/

 
 

Thinkphp的默认缓存方式是以File方式,在/Runtime/Temp 下生成了好多缓存文件。

服务器装了memcached后想给更改成memecache方式

在Conf/config.php 中添加

'DATA_CACHE_TYPE'=>'Memcache', 'MEMCACHE_HOST'   => 'tcp://127.0.0.1:11211' 'DATA_CACHE_TIME'=>'3600',

下载CacheMemcache.class.php 到你的项目中。
Thinkphp 的 Action调用Memcache方法

import("@.ORG.CacheMemcache"); $cache =Cache::getInstance(); $cache->set("uid",'1231'); $cache->get("uid"); $cache->rm("uid"); $cache->clear();

posted @ 2014-04-21 11:50  gzm2012  阅读(175)  评论(0编辑  收藏  举报