TP+Memcache的使用方法
时间:2010-07-15
来源:互联网
首先要开启扩展功能Memcached 端口:11211
ThinkPHP封装的缓存类:CacheMemcache
$Cache = Cache::getInstance('memcache');
//或者:
$options = array('host' => '127.0.0.1', 'port' => 11211, 'timeout' => 10, 'persistent' => false);
$Cache = Cache::getInstance('memcache', $options);
$Cache->set('name','ThinkPHP'); // 缓存name数据
$value = $Cache->get('name'); // 获取缓存的name数据
echo $value;
原始类:Memcache
$mem = new Memcache;
$mem->connect('127.0.0.1', 11211);
$val = $mem->get('key');
if($val == 'test')
{
echo '缓存';
}else{
$mem->set('key', 'test', 0, 60);
echo '写入';
}
ThinkPHP封装的缓存类:CacheMemcache
$Cache = Cache::getInstance('memcache');
//或者:
$options = array('host' => '127.0.0.1', 'port' => 11211, 'timeout' => 10, 'persistent' => false);
$Cache = Cache::getInstance('memcache', $options);
$Cache->set('name','ThinkPHP'); // 缓存name数据
$value = $Cache->get('name'); // 获取缓存的name数据
echo $value;
原始类:Memcache
$mem = new Memcache;
$mem->connect('127.0.0.1', 11211);
$val = $mem->get('key');
if($val == 'test')
{
echo '缓存';
}else{
$mem->set('key', 'test', 0, 60);
echo '写入';
}
作者: dearzxj 发布时间: 2010-07-15
还没用到Memcache
不过支持楼主发经验贴
另外搜索了下
这个可能也有帮助
bbs.thinkphp.cn/viewthread.php?tid=9161
不过支持楼主发经验贴
另外搜索了下
这个可能也有帮助
bbs.thinkphp.cn/viewthread.php?tid=9161
作者: gulize 发布时间: 2010-07-16
tp的S函数是支持那个封装Memcache类的,需要在配置里改一下缓存方式
作者: klgd 发布时间: 2010-07-16
标准版的ThinkPHP包里没有 CacheMemcache.class.php 这个文件。
大家可以在svn里下载他,并放到ThinkPHP\Lib\Think\Util\Cache 下面就可以了。
http://code.google.com/p/thinkph ... he.class.php?r=1887
大家可以在svn里下载他,并放到ThinkPHP\Lib\Think\Util\Cache 下面就可以了。
http://code.google.com/p/thinkph ... he.class.php?r=1887
作者: zg820 发布时间: 2011-05-14
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28