如何设置 CApcCache
我想在函数中使用APC缓存。设置好配置后
'cache' => array(
'class' => 'system.caching.CApcCache',
),
,还是不行。无论我设置什么缓存,它总是返回 false。
$result = '121';
$cache_key = 'key_12';
Yii::app()->cache->set($cache_key,$result,300);
echo Yii::app()->cache->get($cache_key);// always return false
I want to use APC cache in function. After setting up the config
'cache' => array(
'class' => 'system.caching.CApcCache',
),
but it does not work. What ever I set up to cache, it always returns false.
$result = '121';
$cache_key = 'key_12';
Yii::app()->cache->set($cache_key,$result,300);
echo Yii::app()->cache->get($cache_key);// always return false
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
老兄,我对 apc 缓存了解多少,在 main.php 中进行设置后,您不需要执行任何操作。这将为所有 php 代码设置默认缓存。现在,如果您想做类似的事情,那么您应该尝试这样的设置,
这可能会起作用。尝试一下。
Dude, how much I know about apc cache, you don't need to do anything after that settings at main.php. This sets default caching to all the php codes. Now still, if you wanna do something like that, then you should try the settings like this,
This may work. Give it a try.
我在这里为您找到了一些答案: http://www.yiiframework.com/wiki/312/getting-the-most-out-of-apc-for-yii/ 该链接将向您展示如何让 APC 与 Yii 一起工作!
亲切的问候,
I found some answers for you here: http://www.yiiframework.com/wiki/312/getting-the-most-out-of-apc-for-yii/ That link will show you how to get APC working with Yii!
Kind regards,