X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FCache%2FRedisCache.php;h=5dbb963882917d3be47bed7d0383380cb3b9993d;hb=017a57cf1e2b7db6bed4abf7167b4086af73311c;hp=3558a38464ca9c20acdf343b04e31b1a207c9c04;hpb=f8c0f24e34e124ab782d5dcf3d2d658d70e19e5c;p=friendica.git diff --git a/src/Core/Cache/RedisCache.php b/src/Core/Cache/RedisCache.php index 3558a38464..5dbb963882 100644 --- a/src/Core/Cache/RedisCache.php +++ b/src/Core/Cache/RedisCache.php @@ -1,18 +1,35 @@ . + * + */ namespace Friendica\Core\Cache; use Exception; -use Friendica\Core\Config\Configuration; +use Friendica\Core\BaseCache; +use Friendica\Core\Config\IConfig; use Redis; /** * Redis Cache. This driver is based on Memcache driver - * - * @author Hypolite Petovan - * @author Roland Haeder */ -class RedisCache extends Cache implements IMemoryCache +class RedisCache extends BaseCache implements IMemoryCache { /** * @var Redis @@ -22,7 +39,7 @@ class RedisCache extends Cache implements IMemoryCache /** * @throws Exception */ - public function __construct(string $hostname, Configuration $config) + public function __construct(string $hostname, IConfig $config) { if (!class_exists('Redis', false)) { throw new Exception('Redis class isn\'t available'); @@ -96,7 +113,7 @@ class RedisCache extends Cache implements IMemoryCache /** * (@inheritdoc) */ - public function set($key, $value, $ttl = Cache::FIVE_MINUTES) + public function set($key, $value, $ttl = Duration::FIVE_MINUTES) { $cachekey = $this->getCacheKey($key); @@ -122,7 +139,9 @@ class RedisCache extends Cache implements IMemoryCache public function delete($key) { $cachekey = $this->getCacheKey($key); - return ($this->redis->del($cachekey) > 0); + $this->redis->del($cachekey); + // Redis doesn't have an error state for del() + return true; } /** @@ -140,7 +159,7 @@ class RedisCache extends Cache implements IMemoryCache /** * (@inheritdoc) */ - public function add($key, $value, $ttl = Cache::FIVE_MINUTES) + public function add($key, $value, $ttl = Duration::FIVE_MINUTES) { $cachekey = $this->getCacheKey($key); $cached = serialize($value); @@ -151,7 +170,7 @@ class RedisCache extends Cache implements IMemoryCache /** * (@inheritdoc) */ - public function compareSet($key, $oldValue, $newValue, $ttl = Cache::FIVE_MINUTES) + public function compareSet($key, $oldValue, $newValue, $ttl = Duration::FIVE_MINUTES) { $cachekey = $this->getCacheKey($key); @@ -199,6 +218,6 @@ class RedisCache extends Cache implements IMemoryCache */ public function getName() { - return self::TYPE_REDIS; + return Type::REDIS; } }