/** * Deletes all items from cache. * * This should only be used for maintenance purposes (slow performance). */ public function flush() { $keys = $this->redis->keys($this->redis->prefix('*')); foreach ($keys as $key) { $this->redis->del($key); } }
/** * Invalidates data in the cache. * * Will send all affected tags to the cache and ask for hashes having at least one of the provided tags. * Finally it's going to delete all affected items in the cache. */ public function invalidate() { $hashes = []; // Loop trough tags $tags = $this->reflector->getTags(true); foreach ($tags as $tag) { $tag = $this->redis->prefix($tag); // Check if a set exists if (!$this->redis->exists($tag)) { continue; } // Add hashes to collection $hashes += $this->redis->smembers($tag); // Delete tag set $this->redis->del($tag); } // Now delete items $hashes = array_unique($hashes); foreach ($hashes as $hash) { $this->redis->del($hash); } }