get('redis'); if (array_key_exists('password', $redisConfig) && $redisConfig['password'] === '') { unset($redisConfig['password']); } $this->redis = new Client($redisConfig); } /** * Disconnect from redis */ public function __destruct() { $this->redis = null; } /** * Retrieve a value from the cache backend * * @param string $key * @return mixed */ public function get($key) { return json_decode($this->redis->get($key)); } /** * Set a cached value * * @param string $key * @param mixed $value * @return CacheDriverInterface */ public function set($key, $value) { $this->redis->set($key, json_encode($value)); return $this; } /** * Invalidate a cached value * * @param string $key * @return CacheDriverInterface */ public function invalidate($key) { $this->redis->del($key); return $this; } /** * Clear the contents of the cache * * @return void */ public function invalidateAll() { $this->redis->flushDB(); } } // End of RedisDriver.php