thinkphp default to use the file cache data, support memcache and other caching methods, there are two PHP extensions: Memcache and Memcached,memcahe The official note, mainly about memcached.
Relative to PHP memcache,php memcached is based on the native C libmemcached extension, more perfect, proposed to replace the PHP memcached.
Version 3.2.2 starts with a built-in Memcached driver (thinkphp/library/think/cache/driver/memcached.class.php), but the document does not describe the usage, By viewing the source configuration and testing the success.
A bug has not been fixed, that is, the expiration time of 0, the theory should be a permanent cache, but the driver did not do processing, will expire immediately, the Set method is modified as follows
Public functionSet$name,$value,$expire=NULL) {N (' Cache_write ', 1); if(Is_null($expire)) { $expire=$this->options[' expire ']; } $name=$this->options[' prefix '.$name; if(Empty($expire)) $time= 0; Else $time= Time() +$expire; if($this->handler->set ($name,$value,$time)) { if($this->options[' Length ']>0) { //Record Cache Queue $this->queue ($name); } return true; } return false; }
Add in configuration file config.php
// Cache configuration ' Data_cache_type ' = ' Memcached ', array( array(' 127.0.0.1 ', 11211, 0) ),
The driver is called Memcached::addservers (array) to add multiple cache servers
There is also a configuration entry that is Memcached_lib, which is called memcached::setoptions (array)
Refer to the PHP Chinese manual for specific options
Thinkphp using memcached to cache data