ghddru
(249015873)
1
‘cache’=>array(
'class'=>'system.caching.CMemCache',
'servers'=>array(
array('host'=>'server1', 'port'=>11211, 'weight'=>60),
array('host'=>'server2', 'port'=>11211, 'weight'=>40),
),
),
加入这一段以后提示
include(Memcache.php) [<a href=‘function.include’>function.include</a>]: failed to open stream: No such file or directory
要怎么解决?
从来没用过缓存,不懂。望指教
yiqing95
(Yiqing 95)
2
需要先安装memorycache 服务端 http://splinedancer.com/memcached-win32/ 可以看看这个介绍:http://www.ccvita.com/258.html
之后去安装php的memorycache 的扩展:http://www.php.net/manual/en/memcache.installation.php (win下 跟*nix下 自己找)
这两个是你用memorycache的先决条件 要注意php扩展的版本,是否线程安全 要跟你的php一致 可以先试着下载放到ext目录 重启apache 如果失败可以看apache日志 只有跟你的php编译版本一致的扩展才能安装上(nts是非线程安全 ts是线程安全 thread-safe的简写)
正确安装后(phpinfo 可以看到扩展是否安装成功了), 启动memorycache服务端程序(windows下就是memorycached),然后测试
Memcache 这个类就是扩展中的东西 只有安装了才可以找到这个类
ghddru
(249015873)
3
多谢。 我安装成功了。 按照测试可以使用。 但是Yii还是提示错误
D:\wamp\www\yii119\framework\caching\CMemCache.php(143)
131 foreach($config as $c)
132 $this->_servers[]=new CMemCacheServerConfiguration($c);
133 }
134
135 /**
136 * Retrieves a value from cache with a specified key.
137 * This is the implementation of the method declared in the parent class.
138 * @param string $key a unique key identifying the cached value
139 * @return string the value stored in cache, false if the value is not in the cache or expired.
140 */
141 protected function getValue($key)
142 {
143 return $this->_cache->get($key);
144 }
ghddru
(249015873)
4
解决了。 非常感谢。 host改成localhost就可以了。