Neos\Cache\Backend\RedisBackend::freeze PHP Метод

freeze() публичный Метод

All data in a frozen backend remains unchanged and methods which try to add or modify data result in an exception thrown. Possible expiry times of individual cache entries are ignored. A frozen backend can only be thawn by calling the flush() method.
public freeze ( ) : void
Результат void
    public function freeze()
    {
        if ($this->isFrozen()) {
            throw new \RuntimeException(sprintf('Cannot add or modify cache entry because the backend of cache "%s" is frozen.', $this->cacheIdentifier), 1323344192);
        }
        do {
            $entriesKey = $this->buildKey('entries');
            $this->redis->watch($entriesKey);
            $entries = $this->redis->lRange($entriesKey, 0, -1);
            $this->redis->multi();
            foreach ($entries as $entryIdentifier) {
                $this->redis->persist($this->buildKey('entry:' . $entryIdentifier));
            }
            $this->redis->set($this->buildKey('frozen'), 1);
            $result = $this->redis->exec();
        } while ($result === false);
        $this->frozen = true;
    }

Usage Example

 /**
  * @test
  */
 public function freezeInvokesRedis()
 {
     $this->redis->expects($this->once())->method('lRange')->with('Foo_Cache:entries', 0, -1)->will($this->returnValue(['entry_1', 'entry_2']));
     $this->redis->expects($this->exactly(2))->method('persist');
     $this->redis->expects($this->once())->method('set')->with('Foo_Cache:frozen', true);
     $this->backend->freeze();
 }
All Usage Examples Of Neos\Cache\Backend\RedisBackend::freeze