gpt4 book ai didi

cakephp - 为什么 Cache::clear() 不清除我的( View )缓存? (CakePHP)

转载 作者:行者123 更新时间:2023-12-02 00:44:31 25 4
gpt4 key购买 nike

即使它是 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com