This article mainly introduces the usage of memcache in thinkphp. it describes in detail how to install and run memcache and how to use it in ThinkPHP. it is a very useful technique, for more information about how to use memcache in thinkphp, see the example in this article. Share it with you for your reference. The specific analysis is as follows:
1. download and install memcache
① Install memcache in window. download memcached.exe to d:/memcached/memcached.exe. run cmd and enter d:/memcached/memcached.exe-d install to install memcached.exe.
② Run d:/memcached/memcached.exe-d start to start memcache
③ Download php_memcache.dll to the php installation directory extension directory php \ ext
④ Modify php. ini and add extension = php_memcache.dll to restart apache. check phpinfo. php. if the memcache module exists, the installation is successful.
2. use memcache in thinkphp
① ThinkPHP/conf/convention. php modify the cache type
The code is as follows:
'Data _ CACHE_TYPE '=> 'memcaccache', // DATA cache type,
Supported: File | Db | Apc | Memcache | Shmop | Sqlite | Xcache | Apachenote | Eaccelerator
② Thinkphp official download extensions ThinkPHP_Extend_3.1.2/Extend/Driver/Cache/CacheMemcache. class. php save to ThinkPHP/Lib/Driver/Cache/CacheMemcache. class. php
③ Test:
The code is as follows:
S ('test', 'memcache'); $ test = S ('test'); echo $ test;
The memcache output is tested successfully.
I hope this article will help you with ThinkPHP framework programming.