thinkphp memcache cache usage example

WBOY
Release: 2016-07-25 08:52:23
Original
859 people have browsed it
Regarding the usage of memcache in thinkphp, including the installation of memcache, how to use it when running in ThinkPHP, and examples of memcache used as cache in thinkphp, friends in need can refer to it.

Memcache cache usage in thinkphp

1. Download and install memcache 1) Install memcache under window. Download memcached.exe to d:/memcached/memcached.exe. Run cmd and enter: d:/memcached/memcached.exe -d install to install. 2), run d:/memcached/memcached.exe -d start to start memcache 3) Download php_memcache.dll to the php installation directory extension directory phpext 4) Modify php.ini and add extension=php_memcache.dll. Restart apache. Check phpinfo.php. If there is a memcache module, it means the installation is successful

2. Use of memcache in thinkphp 1), ThinkPHP/conf/convention.php modify cache type

'DATA_CACHE_TYPE' => 'Memcache', // Data cache type,

Support: File|Db|Apc|Memcache|Shmop|Sqlite|Xcache|Apachenote|Eaccelerator 2). Thinkphp official download extension ThinkPHP_Extend_3.1.2/Extend/Driver/Cache/CacheMemcache.class.php and save it to: ThinkPHP/Lib/Driver/Cache/CacheMemcache.class.php

3), test:

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

Output memcache, indicating that the test is successful.



source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!