CakePHP 1.3 clears all cached pages after adding a new publication

I am using CakePHP 1.3 and trying to turn on the cache for viewing pages, the caching system works fine and caches all pages. But when we add a new record (insert a new record into the database) or edit the old one (update the table record) CakePHP deletes all cached pages, not just the edited page!

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), 
);

How can I tell Cake to delete only the cached version of the modified page, and not all cached pages?

+4
source share
1 answer

, , . 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
}

, , ( ).

, , , , . .

+1

Source: https://habr.com/ru/post/1529837/


All Articles