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:
parent
86bf2ee45a
commit
34e4968c06
19 changed files with 149 additions and 64 deletions
|
@ -153,4 +153,9 @@ class APCuCache extends AbstractCache implements IMemoryCache
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return self::TYPE_APCU;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -92,4 +92,9 @@ class ArrayCache extends AbstractCache implements IMemoryCache
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return self::TYPE_ARRAY;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,4 +152,9 @@ class ProfilerCache implements ICache, IMemoryCache
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return (string)$this->cache . ' (with profiler)';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,4 +192,9 @@ class RedisCache extends AbstractCache implements IMemoryCache
|
|||
$this->redis->unwatch();
|
||||
return false;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return self::TYPE_REDIS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue