Usage of memcache in thinkphp _ php instance

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.