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

标签 cakephp caching

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

相关文章:

php - 在将现有的 php 应用程序移植到 CakePHP 时,如何为模型使用非标准表/列名称?

php - CakePHP,如何从另一个表获取值

node.js - 如何在node.js中获取CNAME记录的权威TTL值?

caching - Nginx FastCGI 缓存 VS Varnish?

python-3.x - 为什么 lru_cache 比作为以下斐波那契计算器的字典实现的缓存慢?

ios - 核心数据 - 禁用从缓存加载

cakephp - 在 customHelper 中使用 $this->element

php - 是否可以将一个数组的字段存储为一个新数组?

php - 在启用 crsf 和安全组件的 cakephp 3.4 中通过 ajax 发送表单

java - GWT 中静态文件的缓存