Cache invalidation with TAG

3 years ago

tivvit
Member | 36
+
0
-

Hi,

I am using Nette\Cache currently with redis, but I have the same problem with file cache too.

When I do this:

return $this->cache->load($date, function (& $dependencies) use ($date) {
            $dependencies = array(
                Caching\Cache::TAGS => array("a"),
            );

            ...
            return ...;

and then this:

$this->cache->clean(array(
    Caching\Cache::TAGS => array("a")
));

the cache is not invalidated.

But when I do this:

return $this->cache->load($date, function (& $dependencies) use ($date) {
            $dependencies = array(
                Caching\Cache::EXPIRATION => time(),
// or this      Caching\Cache::EXPIRE => '1 seconds',
            );

or even this:

$this->cache->clean(array(
    Caching\Cache::ALL => true,
));

It works perfectly.

Versions:

"require": {
        "php": "~5.4.0",
        "nette/application": "~2.3.0",
        "nette/bootstrap": "~2.3.0",
        "nette/caching": "~2.3.0",
...

Thanks in advance.