即使它是 documented CakePHP 会在更新模型时自动清除 View 缓存,但事实并非如此。
It is important to remember that Cake will clear a cached view if a model used in the cached view is modified. For example, if a cached view uses data from the Post model, and there has been an INSERT, UPDATE, or DELETE query made to a Post, the cache for that view is cleared, and new content is generated on the next request.
即使手动调用建议的 Cache::clear()
方法也无济于事。如何清除 Cake 中的 View 缓存?
(从版本 1.2.2.8120
开始。查看存储库提交,即使是 .8256 也应该有这个问题。)
最佳答案
使用 clearCache()
,可能在模型 afterSave
回调中自动执行:
// model file:
function afterSave($created) {
clearCache();
}
(请同时记录其他可用的解决方案,这是我唯一能找到的解决方案。)
关于cakephp - 为什么 Cache::clear() 不清除我的( View )缓存? (CakePHP),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1183701/