CakePHP 1.3在添加新帖子后清除所有缓存页面

CakePHP 1.3在添加新帖子后清除所有缓存页面,cakephp,caching,cakephp-1.3,Cakephp,Caching,Cakephp 1.3,我正在使用CakePHP1.3,并尝试为视图页面启用缓存,缓存系统工作正常,缓存所有页面。但当我们添加一个新帖子(向数据库插入新记录)或编辑一个旧帖子(更新表的记录)时,CakePHP会删除所有缓存页面,而不仅仅是编辑过的页面 app/config/core.php: Cache::config('default', array('engine' => 'File','duration' => 8640000)); app/controllers/articles_controll

我正在使用CakePHP1.3,并尝试为视图页面启用缓存,缓存系统工作正常,缓存所有页面。但当我们添加一个新帖子(向数据库插入新记录)或编辑一个旧帖子(更新表的记录)时,CakePHP会删除所有缓存页面,而不仅仅是编辑过的页面

app/config/core.php:

Cache::config('default', array('engine' => 'File','duration' => 8640000));
app/controllers/articles_controller.php:

var $helpers = array('Cache');
var $cacheAction = array(
    'view' => array('duration' => 8640000), 
    'latest' => array('duration' => 8640000), 
);

我如何告诉Cake只删除已更改页面的缓存版本,而不是所有缓存页面?

这实际上相当困难,所以我不能给您一段代码来解决这个问题。您需要编辑lib文件夹中管理缓存的实际蛋糕文件。注:这是超级不推荐的蛋糕人。但是,
lib/Cake/Cache/Engine/FileEngine.php
是包含文件引擎操作的文件。您似乎对删除功能感兴趣:

/**
 * Delete a key from the cache
 *
 * @param string $key Identifier for the data
 * @return boolean True if the value was successfully deleted, false if it didn't exist or couldn't be removed
 */
public function delete($key) {
    if ($this->_setKey($key) === false || !$this->_init) {
        return false;
    }
    $path = $this->_File->getRealPath();
    $this->_File = null;

    //@codingStandardsIgnoreStart
    return @unlink($path);
    //@codingStandardsIgnoreEnd
}
此外,您可以添加自己的文件引擎,并通过移动代码并在其中扩展代码(这在开源中非常酷)来使用分开的蛋糕引擎,而不是编辑核心蛋糕文件


也可能通过阅读用于实现文件缓存引擎的代码,您会找到实际的解决方案。祝你好运。

谢谢桑普森先生的编辑。你知道我怎样才能解决这个问题吗?