1
0
Fork 0

Adding possibility to use a different cache-backend for locking and caching

- Renaming *LockDriver to *Lock since it isn't a "driver" anymore
This commit is contained in:
Philipp Holzer 2019-08-04 15:42:39 +02:00
commit 34e4968c06
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
19 changed files with 149 additions and 64 deletions

View file

@ -153,4 +153,9 @@ class APCuCache extends AbstractCache implements IMemoryCache
return true;
}
public function __toString()
{
return self::TYPE_APCU;
}
}

View file

@ -11,6 +11,20 @@ namespace Friendica\Core\Cache;
*/
abstract class AbstractCache implements ICache
{
const TYPE_APCU = 'apcu';
const TYPE_ARRAY = 'array';
const TYPE_DATABASE = 'database';
const TYPE_MEMCACHE = 'memcache';
const TYPE_MEMCACHED = 'memcached';
const TYPE_REDIS = 'redis';
/**
* Force each Cache implementation to define the ToString method
*
* @return string
*/
abstract function __toString();
/**
* @var string The hostname
*/

View file

@ -92,4 +92,9 @@ class ArrayCache extends AbstractCache implements IMemoryCache
return false;
}
}
public function __toString()
{
return self::TYPE_ARRAY;
}
}

View file

@ -110,4 +110,9 @@ class DatabaseCache extends AbstractCache implements ICache
return $this->dba->delete('cache', ['`k` IS NOT NULL ']);
}
}
public function __toString()
{
return self::TYPE_DATABASE;
}
}

View file

@ -148,4 +148,9 @@ class MemcacheCache extends AbstractCache implements IMemoryCache
$cachekey = $this->getCacheKey($key);
return $this->memcache->add($cachekey, serialize($value), MEMCACHE_COMPRESSED, $ttl);
}
public function __toString()
{
return self::TYPE_MEMCACHE;
}
}

View file

@ -151,4 +151,9 @@ class MemcachedCache extends AbstractCache implements IMemoryCache
$cachekey = $this->getCacheKey($key);
return $this->memcached->add($cachekey, $value, $ttl);
}
public function __toString()
{
return self::TYPE_MEMCACHED;
}
}

View file

@ -152,4 +152,9 @@ class ProfilerCache implements ICache, IMemoryCache
return false;
}
}
public function __toString()
{
return (string)$this->cache . ' (with profiler)';
}
}

View file

@ -192,4 +192,9 @@ class RedisCache extends AbstractCache implements IMemoryCache
$this->redis->unwatch();
return false;
}
public function __toString()
{
return self::TYPE_REDIS;
}
}

View file

@ -5,7 +5,7 @@ namespace Friendica\Core\Lock;
use Friendica\Core\Cache;
use Friendica\Core\Cache\IMemoryCache;
class CacheLockDriver extends AbstractLock
class CacheLock extends AbstractLock
{
/**
* @var \Friendica\Core\Cache\ICache;
@ -13,7 +13,7 @@ class CacheLockDriver extends AbstractLock
private $cache;
/**
* CacheLockDriver constructor.
* CacheLock constructor.
*
* @param IMemoryCache $cache The CacheDriver for this type of lock
*/