Zend 缓存不启动
好吧,问题来了:
$frontendOptions = array(
'lifetime' => 7200,
'debug_header' => true, // for debugging, but it doesn't work...
'regexps' => array(
// Cache the static pages
'^/pages/' => array('cache' => true),
)
);
$backendOptions = $config->cache->backOptions->toArray();
// getting a Zend_Cache_Frontend_Page object
require_once 'Zend/Cache.php';
$cache = Zend_Cache::factory('Page',
$config->cache->backend,
$frontendOptions,
$backendOptions);
$cache->start();
这根本没有任何作用。页面加载时间完全相同,并且 $backendOptions
中指示的文件夹为空。我做错了什么?
顺便说一句:$config->cache->backend
读取“file”
。
Ok, here's the problem:
$frontendOptions = array(
'lifetime' => 7200,
'debug_header' => true, // for debugging, but it doesn't work...
'regexps' => array(
// Cache the static pages
'^/pages/' => array('cache' => true),
)
);
$backendOptions = $config->cache->backOptions->toArray();
// getting a Zend_Cache_Frontend_Page object
require_once 'Zend/Cache.php';
$cache = Zend_Cache::factory('Page',
$config->cache->backend,
$frontendOptions,
$backendOptions);
$cache->start();
This doesn't do anything at all. Page loading times are exactly the same and the folder indicated in $backendOptions
is empty. What am I doing wrong?
By the way: $config->cache->backend
reads "file"
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,按照我回答自己问题的传统,这里有答案,还有一个子问题,如果有人知道发生了什么的话:
基本上,如果你碰巧运行比 Hello World 更高级的东西,这个东西就不能开箱即用。 。我有一个 cookie 集,因为它找到了一个 cookie,所以它拒绝对此做任何事情,所以在缓存代码中挖掘了一个小时后,我发现所需的魔法只是设置
,好吧,因为所有 cookie 或多或少都是唯一的,并且我真的不想关心它们,我设置了
所以现在它工作完美。
感谢 Chris 和 smoove 抽出时间,现在事后看来,你们的评论很有意义。当然,我没有任何错误或警告,并且“文件”确实是大写的。
我现在想知道是否可以在某些情况下发送一个峰值来删除正确的缓存文件。我可以锤击它(复制缓存中的 ID 生成器并 unset() 正确的目标),但可能有一个更奇特的解决方案。如果您有任何想法,请告诉我。
Well, following my tradition of answering my own questions, here comes the answer, and a subquestion, if anyone knows what's going on:
Basically, this thing doesn't work out of the box if you happen to run something more advanced than Hello World. I had a cookie set and since it found a cookie, it refused to do anything about it, so one hour digging in the caching code I discovered that the magic needed was simply to set
And well, since all cookies are more or less unique and I don't really want to care about them, I set
So now it works flawlessly.
Thanks to Chris and smoove for taking the time out and now in hindsight your comments made a lot of sense. Naturally though, I didn't have any errors or warnings and "File" was indeed spelled with uppercase.
What I wonder now is if I can send a spike to delete the proper cache file upon certain circumstances. I can hammer it (copy the ID generator in the cache and unset() the proper target), but there might be a fancier solution. If you have any idea, let me know.
请前往 config/application.ini 并设置:
Please go to config/application.ini and set:
如果您已完成 config/application.ini ,只需复制并粘贴下面的代码即可享受乐趣。
请记住临时文件;我在这里使用了 servercache,你可以使用 temp 或 tmp 或任何其他。
If you are done with config/application.ini , just copy and past the code below and have fun.
Please do remember the temporary file ; I have used here servercache you can use temp or tmp or whatsoever.