Home  >  Article  >  php教程  >  thinkphp中memcache的用法实例,thinkphpmemcache

thinkphp中memcache的用法实例,thinkphpmemcache

WBOY
WBOYOriginal
2016-06-13 09:19:48877browse

thinkphp中memcache的用法实例,thinkphpmemcache

本文实例讲述了thinkphp中memcache的用法。分享给大家供大家参考。具体分析如下:

1、下载并安装memcache

① window下安装memcache. 下载memcached.exe 到d:/memcached/memcached.exe.在运行cmd 输入                d:/memcached/memcached.exe -d install安装 。

② 运行d:/memcached/memcached.exe -d start 启动memcache

③ 下载php_memcache.dll 到php安装目录扩展目录 php\ext

④ 修改php.ini 加入 extension=php_memcache.dll 重启apache.查看phpinfo.php 如果有memcache模块 则      说明安装成功

2、thinkphp 中memcache 的使用

① ThinkPHP/conf/convention.php 修改缓存类型

复制代码 代码如下:

'DATA_CACHE_TYPE'       => 'Memcache',  // 数据缓存类型,

支持: File|Db|Apc|Memcache|Shmop|Sqlite|Xcache|Apachenote|Eaccelerator

② thinkphp官方下载扩展ThinkPHP_Extend_3.1.2/Extend/Driver/Cache/CacheMemcache.class.php 保存到  ThinkPHP/Lib/Driver/Cache/CacheMemcache.class.php

③ 测试:

复制代码 代码如下:

S('test','memcache');$test = S('test'); echo $test;

输出memcache 测试成功。

希望本文所述对大家的ThinkPHP框架程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn