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

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

The flush method will use the EVAL command to flush all entries and tags for this cache in an atomic way.
public flush ( ) : void
Результат void
    public function flush()
    {
        $script = "\n\t\tlocal entries = redis.call('LRANGE',KEYS[1],0,-1)\n\t\tfor k1,entryIdentifier in ipairs(entries) do\n\t\t\tredis.call('DEL', ARGV[1]..'entry:'..entryIdentifier)\n\t\t\tlocal tags = redis.call('SMEMBERS', ARGV[1]..'tags:'..entryIdentifier)\n\t\t\tfor k2,tagName in ipairs(tags) do\n\t\t\t\tredis.call('DEL', ARGV[1]..'tag:'..tagName)\n\t\t\tend\n\t\t\tredis.call('DEL', ARGV[1]..'tags:'..entryIdentifier)\n\t\tend\n\t\tredis.call('DEL', KEYS[1])\n\t\tredis.call('DEL', KEYS[2])\n\t\t";
        $this->redis->eval($script, [$this->buildKey('entries'), $this->buildKey('frozen'), $this->buildKey('')], 2);
        $this->frozen = null;
    }

Usage Example

 /**
  * @test
  */
 public function flushFlushesCache()
 {
     for ($i = 0; $i < 10; $i++) {
         $this->backend->set('entry_' . $i, 'foo', ['tag1']);
     }
     $this->assertTrue($this->backend->has('entry_5'));
     $this->backend->flush();
     $this->assertFalse($this->backend->has('entry_5'));
 }