|
本文实例讲述了thinkPHP实现MemCache分布式缓存功能。分享给大家供大家参考,具体如下:
两天在研究MemCache分布式缓存的问题时,发现ThinkPHP其实并不支持分布式缓存功能,这可以从官方提供的CacheMemcache.class.php文件中看到:
if(empty($options)) {
$options = array
(
'host' => '127.0.0.1',
'port' => 11211,
'timeout' => false,
'persistent' => false
);
}
$func = $options['persistent'] ? 'pconnect' : 'connect';
$this->expire = isset($options['expire'])?$options['expire']:C('DATA_CACHE_TIME');
$this->handler = new Memcache;
$this->connected = $options['timeout'] === false ?
$this->handler->$func($options['host'], $options['port']) :
$this->handler->$func($options['host'], $options['port'], $options['timeout']);
|
|