Rename *CacheDriver to *Cache because they don't act as driver anymore

This commit is contained in:
Philipp Holzer 2019-08-04 10:26:53 +02:00
parent d56bd28a07
commit 86bf2ee45a
No known key found for this signature in database
GPG Key ID: D8365C3D36B77D90
38 changed files with 152 additions and 144 deletions

View File

@ -4,7 +4,7 @@ namespace Friendica\Console;
use Asika\SimpleConsole\CommandArgsException; use Asika\SimpleConsole\CommandArgsException;
use Friendica\App; use Friendica\App;
use Friendica\Core\Cache\ICacheDriver; use Friendica\Core\Cache\ICache;
use Friendica\Core\Config\Configuration; use Friendica\Core\Config\Configuration;
use Friendica\Factory\CacheDriverFactory; use Friendica\Factory\CacheDriverFactory;
use RuntimeException; use RuntimeException;
@ -33,7 +33,7 @@ class Cache extends \Asika\SimpleConsole\Console
private $cacheDriverName; private $cacheDriverName;
/** /**
* @var ICacheDriver * @var ICache
*/ */
private $cache; private $cache;
@ -71,7 +71,7 @@ HELP;
return $help; return $help;
} }
public function __construct(App\Mode $appMode, Configuration $config, ICacheDriver $cache, array $argv = null) public function __construct(App\Mode $appMode, Configuration $config, ICache $cache, array $argv = null)
{ {
parent::__construct($argv); parent::__construct($argv);
@ -161,7 +161,7 @@ HELP;
if (count($this->args) >= 3) { if (count($this->args) >= 3) {
$key = $this->getArgument(1); $key = $this->getArgument(1);
$value = $this->getArgument(2); $value = $this->getArgument(2);
$duration = intval($this->getArgument(3, ICacheDriver::FIVE_MINUTES)); $duration = intval($this->getArgument(3, ICache::FIVE_MINUTES));
if (is_array($this->cache->get($key))) { if (is_array($this->cache->get($key))) {
throw new RuntimeException("$key is an array and can't be set using this command."); throw new RuntimeException("$key is an array and can't be set using this command.");

View File

@ -5,31 +5,31 @@
namespace Friendica\Core; namespace Friendica\Core;
use Friendica\BaseObject; use Friendica\BaseObject;
use Friendica\Core\Cache\ICacheDriver; use Friendica\Core\Cache\ICache;
/** /**
* @brief Class for storing data for a short time * @brief Class for storing data for a short time
*/ */
class Cache extends BaseObject class Cache extends BaseObject
{ {
/** @deprecated Use ICacheDriver::MONTH */ /** @deprecated Use ICache::MONTH */
const MONTH = ICacheDriver::MONTH; const MONTH = ICache::MONTH;
/** @deprecated Use ICacheDriver::WEEK */ /** @deprecated Use ICache::WEEK */
const WEEK = 604800; const WEEK = ICache::WEEK;
/** @deprecated Use ICacheDriver::DAY */ /** @deprecated Use ICache::DAY */
const DAY = 86400; const DAY = ICache::DAY;
/** @deprecated Use ICacheDriver::HOUR */ /** @deprecated Use ICache::HOUR */
const HOUR = 3600; const HOUR = ICache::HOUR;
/** @deprecated Use ICacheDriver::HALF_HOUR */ /** @deprecated Use ICache::HALF_HOUR */
const HALF_HOUR = 1800; const HALF_HOUR = ICache::HALF_HOUR;
/** @deprecated Use ICacheDriver::QUARTER_HOUR */ /** @deprecated Use ICache::QUARTER_HOUR */
const QUARTER_HOUR = 900; const QUARTER_HOUR = ICache::QUARTER_HOUR;
/** @deprecated Use ICacheDriver::FIVE_MINUTES */ /** @deprecated Use ICache::FIVE_MINUTES */
const FIVE_MINUTES = 300; const FIVE_MINUTES = ICache::FIVE_MINUTES;
/** @deprecated Use ICacheDriver::MINUTE */ /** @deprecated Use ICache::MINUTE */
const MINUTE = 60; const MINUTE = ICache::MINUTE;
/** @deprecated Use ICacheDriver::INFINITE */ /** @deprecated Use ICache::INFINITE */
const INFINITE = 0; const INFINITE = ICache::INFINITE;
/** /**
* @brief Returns all the cache keys sorted alphabetically * @brief Returns all the cache keys sorted alphabetically
@ -41,7 +41,7 @@ class Cache extends BaseObject
*/ */
public static function getAllKeys($prefix = null) public static function getAllKeys($prefix = null)
{ {
return self::getClass(ICacheDriver::class)->getAllKeys($prefix); return self::getClass(ICache::class)->getAllKeys($prefix);
} }
/** /**
@ -54,7 +54,7 @@ class Cache extends BaseObject
*/ */
public static function get($key) public static function get($key)
{ {
return self::getClass(ICacheDriver::class)->get($key); return self::getClass(ICache::class)->get($key);
} }
/** /**
@ -69,9 +69,9 @@ class Cache extends BaseObject
* @return bool * @return bool
* @throws \Exception * @throws \Exception
*/ */
public static function set($key, $value, $duration = ICacheDriver::MONTH) public static function set($key, $value, $duration = ICache::MONTH)
{ {
return self::getClass(ICacheDriver::class)->set($key, $value, $duration); return self::getClass(ICache::class)->set($key, $value, $duration);
} }
/** /**
@ -84,7 +84,7 @@ class Cache extends BaseObject
*/ */
public static function delete($key) public static function delete($key)
{ {
return self::getClass(ICacheDriver::class)->delete($key); return self::getClass(ICache::class)->delete($key);
} }
/** /**
@ -97,6 +97,6 @@ class Cache extends BaseObject
*/ */
public static function clear($outdated = true) public static function clear($outdated = true)
{ {
return self::getClass(ICacheDriver::class)->clear($outdated); return self::getClass(ICache::class)->clear($outdated);
} }
} }

View File

@ -6,11 +6,11 @@ use Exception;
use Friendica\Core\Cache; use Friendica\Core\Cache;
/** /**
* APCu Cache Driver. * APCu Cache.
* *
* @author Philipp Holzer <admin@philipp.info> * @author Philipp Holzer <admin@philipp.info>
*/ */
class APCuCache extends AbstractCacheDriver implements IMemoryCacheDriver class APCuCache extends AbstractCache implements IMemoryCache
{ {
use TraitCompareSet; use TraitCompareSet;
use TraitCompareDelete; use TraitCompareDelete;

View File

@ -5,11 +5,11 @@ namespace Friendica\Core\Cache;
/** /**
* Abstract class for common used functions * Abstract class for common used functions
* *
* Class AbstractCacheDriver * Class AbstractCache
* *
* @package Friendica\Core\Cache * @package Friendica\Core\Cache
*/ */
abstract class AbstractCacheDriver implements ICacheDriver abstract class AbstractCache implements ICache
{ {
/** /**
* @var string The hostname * @var string The hostname

View File

@ -5,13 +5,13 @@ namespace Friendica\Core\Cache;
use Friendica\Core\Cache; use Friendica\Core\Cache;
/** /**
* Implementation of the IMemoryCacheDriver mainly for testing purpose * Implementation of the IMemoryCache mainly for testing purpose
* *
* Class ArrayCache * Class ArrayCache
* *
* @package Friendica\Core\Cache * @package Friendica\Core\Cache
*/ */
class ArrayCache extends AbstractCacheDriver implements IMemoryCacheDriver class ArrayCache extends AbstractCache implements IMemoryCache
{ {
use TraitCompareDelete; use TraitCompareDelete;

View File

@ -7,11 +7,11 @@ use Friendica\Database\Database;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
/** /**
* Database Cache Driver * Database Cache
* *
* @author Hypolite Petovan <hypolite@mrpetovan.com> * @author Hypolite Petovan <hypolite@mrpetovan.com>
*/ */
class DatabaseCacheDriver extends AbstractCacheDriver implements ICacheDriver class DatabaseCache extends AbstractCache implements ICache
{ {
/** /**
* @var Database * @var Database

View File

@ -3,11 +3,11 @@
namespace Friendica\Core\Cache; namespace Friendica\Core\Cache;
/** /**
* Cache Driver Interface * Cache Interface
* *
* @author Hypolite Petovan <hypolite@mrpetovan.com> * @author Hypolite Petovan <hypolite@mrpetovan.com>
*/ */
interface ICacheDriver interface ICache
{ {
const MONTH = 2592000; const MONTH = 2592000;
const WEEK = 604800; const WEEK = 604800;

View File

@ -5,11 +5,11 @@ namespace Friendica\Core\Cache;
/** /**
* This interface defines methods for Memory-Caches only * This interface defines methods for Memory-Caches only
* *
* Interface IMemoryCacheDriver * Interface IMemoryCache
* *
* @package Friendica\Core\Cache * @package Friendica\Core\Cache
*/ */
interface IMemoryCacheDriver extends ICacheDriver interface IMemoryCache extends ICache
{ {
/** /**
* Sets a value if it's not already stored * Sets a value if it's not already stored
@ -19,7 +19,7 @@ interface IMemoryCacheDriver extends ICacheDriver
* @param int $ttl The cache lifespan, must be one of the Cache constants * @param int $ttl The cache lifespan, must be one of the Cache constants
* @return bool * @return bool
*/ */
public function add($key, $value, $ttl = ICacheDriver::FIVE_MINUTES); public function add($key, $value, $ttl = ICache::FIVE_MINUTES);
/** /**
* Compares if the old value is set and sets the new value * Compares if the old value is set and sets the new value
@ -31,7 +31,7 @@ interface IMemoryCacheDriver extends ICacheDriver
* *
* @return bool * @return bool
*/ */
public function compareSet($key, $oldValue, $newValue, $ttl = ICacheDriver::FIVE_MINUTES); public function compareSet($key, $oldValue, $newValue, $ttl = ICache::FIVE_MINUTES);
/** /**
* Compares if the old value is set and removes it * Compares if the old value is set and removes it

View File

@ -8,11 +8,11 @@ use Friendica\Core\Config\Configuration;
use Memcache; use Memcache;
/** /**
* Memcache Cache Driver * Memcache Cache
* *
* @author Hypolite Petovan <hypolite@mrpetovan.com> * @author Hypolite Petovan <hypolite@mrpetovan.com>
*/ */
class MemcacheCacheDriver extends AbstractCacheDriver implements IMemoryCacheDriver class MemcacheCache extends AbstractCache implements IMemoryCache
{ {
use TraitCompareSet; use TraitCompareSet;
use TraitCompareDelete; use TraitCompareDelete;

View File

@ -9,11 +9,11 @@ use Memcached;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
/** /**
* Memcached Cache Driver * Memcached Cache
* *
* @author Hypolite Petovan <hypolite@mrpetovan.com> * @author Hypolite Petovan <hypolite@mrpetovan.com>
*/ */
class MemcachedCacheDriver extends AbstractCacheDriver implements IMemoryCacheDriver class MemcachedCache extends AbstractCache implements IMemoryCache
{ {
use TraitCompareSet; use TraitCompareSet;
use TraitCompareDelete; use TraitCompareDelete;

View File

@ -11,10 +11,10 @@ use Friendica\Util\Profiler;
* *
* It is using the decorator pattern (@see * It is using the decorator pattern (@see
*/ */
class ProfilerCache implements ICacheDriver, IMemoryCacheDriver class ProfilerCache implements ICache, IMemoryCache
{ {
/** /**
* @var ICacheDriver The original cache driver * @var ICache The original cache driver
*/ */
private $cache; private $cache;
@ -23,7 +23,7 @@ class ProfilerCache implements ICacheDriver, IMemoryCacheDriver
*/ */
private $profiler; private $profiler;
public function __construct(ICacheDriver $cache, Profiler $profiler) public function __construct(ICache $cache, Profiler $profiler)
{ {
$this->cache = $cache; $this->cache = $cache;
$this->profiler = $profiler; $this->profiler = $profiler;
@ -104,7 +104,7 @@ class ProfilerCache implements ICacheDriver, IMemoryCacheDriver
*/ */
public function add($key, $value, $ttl = Cache::FIVE_MINUTES) public function add($key, $value, $ttl = Cache::FIVE_MINUTES)
{ {
if ($this->cache instanceof IMemoryCacheDriver) { if ($this->cache instanceof IMemoryCache) {
$time = microtime(true); $time = microtime(true);
$return = $this->cache->add($key, $value, $ttl); $return = $this->cache->add($key, $value, $ttl);
@ -122,7 +122,7 @@ class ProfilerCache implements ICacheDriver, IMemoryCacheDriver
*/ */
public function compareSet($key, $oldValue, $newValue, $ttl = Cache::FIVE_MINUTES) public function compareSet($key, $oldValue, $newValue, $ttl = Cache::FIVE_MINUTES)
{ {
if ($this->cache instanceof IMemoryCacheDriver) { if ($this->cache instanceof IMemoryCache) {
$time = microtime(true); $time = microtime(true);
$return = $this->cache->compareSet($key, $oldValue, $newValue, $ttl); $return = $this->cache->compareSet($key, $oldValue, $newValue, $ttl);
@ -140,7 +140,7 @@ class ProfilerCache implements ICacheDriver, IMemoryCacheDriver
*/ */
public function compareDelete($key, $value) public function compareDelete($key, $value)
{ {
if ($this->cache instanceof IMemoryCacheDriver) { if ($this->cache instanceof IMemoryCache) {
$time = microtime(true); $time = microtime(true);
$return = $this->cache->compareDelete($key, $value); $return = $this->cache->compareDelete($key, $value);

View File

@ -8,12 +8,12 @@ use Friendica\Core\Config\Configuration;
use Redis; use Redis;
/** /**
* Redis Cache Driver. This driver is based on Memcache driver * Redis Cache. This driver is based on Memcache driver
* *
* @author Hypolite Petovan <hypolite@mrpetovan.com> * @author Hypolite Petovan <hypolite@mrpetovan.com>
* @author Roland Haeder <roland@mxchange.org> * @author Roland Haeder <roland@mxchange.org>
*/ */
class RedisCacheDriver extends AbstractCacheDriver implements IMemoryCacheDriver class RedisCache extends AbstractCache implements IMemoryCache
{ {
/** /**
* @var Redis * @var Redis

View File

@ -8,8 +8,8 @@
namespace Friendica\Core; namespace Friendica\Core;
use Friendica\BaseObject; use Friendica\BaseObject;
use Friendica\Core\Cache\ICacheDriver; use Friendica\Core\Cache\ICache;
use Friendica\Core\Lock\ILockDriver; use Friendica\Core\Lock\ILock;
/** /**
* This class contain Functions for preventing parallel execution of functions * This class contain Functions for preventing parallel execution of functions
@ -26,9 +26,9 @@ class Lock extends BaseObject
* @return boolean Was the lock successful? * @return boolean Was the lock successful?
* @throws \Exception * @throws \Exception
*/ */
public static function acquire($key, $timeout = 120, $ttl = ICacheDriver::FIVE_MINUTES) public static function acquire($key, $timeout = 120, $ttl = ICache::FIVE_MINUTES)
{ {
return self::getClass(ILockDriver::class)->acquireLock($key, $timeout, $ttl); return self::getClass(ILock::class)->acquireLock($key, $timeout, $ttl);
} }
/** /**
@ -42,7 +42,7 @@ class Lock extends BaseObject
*/ */
public static function release($key, $override = false) public static function release($key, $override = false)
{ {
return self::getClass(ILockDriver::class)->releaseLock($key, $override); return self::getClass(ILock::class)->releaseLock($key, $override);
} }
/** /**
@ -52,6 +52,6 @@ class Lock extends BaseObject
*/ */
public static function releaseAll() public static function releaseAll()
{ {
self::getClass(ILockDriver::class)->releaseAll(); self::getClass(ILock::class)->releaseAll();
} }
} }

View File

@ -3,13 +3,13 @@
namespace Friendica\Core\Lock; namespace Friendica\Core\Lock;
/** /**
* Class AbstractLockDriver * Class AbstractLock
* *
* @package Friendica\Core\Lock * @package Friendica\Core\Lock
* *
* Basic class for Locking with common functions (local acquired locks, releaseAll, ..) * Basic class for Locking with common functions (local acquired locks, releaseAll, ..)
*/ */
abstract class AbstractLockDriver implements ILockDriver abstract class AbstractLock implements ILock
{ {
/** /**
* @var array The local acquired locks * @var array The local acquired locks

View File

@ -3,21 +3,21 @@
namespace Friendica\Core\Lock; namespace Friendica\Core\Lock;
use Friendica\Core\Cache; use Friendica\Core\Cache;
use Friendica\Core\Cache\IMemoryCacheDriver; use Friendica\Core\Cache\IMemoryCache;
class CacheLockDriver extends AbstractLockDriver class CacheLockDriver extends AbstractLock
{ {
/** /**
* @var \Friendica\Core\Cache\ICacheDriver; * @var \Friendica\Core\Cache\ICache;
*/ */
private $cache; private $cache;
/** /**
* CacheLockDriver constructor. * CacheLockDriver constructor.
* *
* @param IMemoryCacheDriver $cache The CacheDriver for this type of lock * @param IMemoryCache $cache The CacheDriver for this type of lock
*/ */
public function __construct(IMemoryCacheDriver $cache) public function __construct(IMemoryCache $cache)
{ {
$this->cache = $cache; $this->cache = $cache;
} }

View File

@ -9,7 +9,7 @@ use Friendica\Util\DateTimeFormat;
/** /**
* Locking driver that stores the locks in the database * Locking driver that stores the locks in the database
*/ */
class DatabaseLockDriver extends AbstractLockDriver class DatabaseLock extends AbstractLock
{ {
/** /**
* The current ID of the process * The current ID of the process

View File

@ -5,11 +5,11 @@ namespace Friendica\Core\Lock;
use Friendica\Core\Cache; use Friendica\Core\Cache;
/** /**
* Lock Driver Interface * Lock Interface
* *
* @author Philipp Holzer <admin@philipp.info> * @author Philipp Holzer <admin@philipp.info>
*/ */
interface ILockDriver interface ILock
{ {
/** /**
* Checks, if a key is currently locked to a or my process * Checks, if a key is currently locked to a or my process
@ -30,7 +30,7 @@ interface ILockDriver
* *
* @return boolean Was the lock successful? * @return boolean Was the lock successful?
*/ */
public function acquireLock($key, $timeout = 120, $ttl = Cache\ICacheDriver::FIVE_MINUTES); public function acquireLock($key, $timeout = 120, $ttl = Cache\ICache::FIVE_MINUTES);
/** /**
* Releases a lock if it was set by us * Releases a lock if it was set by us

View File

@ -4,7 +4,7 @@ namespace Friendica\Core\Lock;
use Friendica\Core\Cache; use Friendica\Core\Cache;
class SemaphoreLockDriver extends AbstractLockDriver class SemaphoreLock extends AbstractLock
{ {
private static $semaphore = []; private static $semaphore = [];

View File

@ -3,7 +3,7 @@
namespace Friendica\Factory; namespace Friendica\Factory;
use Friendica\Core\Cache; use Friendica\Core\Cache;
use Friendica\Core\Cache\ICacheDriver; use Friendica\Core\Cache\ICache;
use Friendica\Core\Config\Configuration; use Friendica\Core\Config\Configuration;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\Util\BaseURL; use Friendica\Util\BaseURL;
@ -61,7 +61,7 @@ class CacheDriverFactory
/** /**
* This method creates a CacheDriver for the given cache driver name * This method creates a CacheDriver for the given cache driver name
* *
* @return ICacheDriver The instance of the CacheDriver * @return ICache The instance of the CacheDriver
* @throws \Exception The exception if something went wrong during the CacheDriver creation * @throws \Exception The exception if something went wrong during the CacheDriver creation
*/ */
public function create() public function create()
@ -70,19 +70,19 @@ class CacheDriverFactory
switch ($driver) { switch ($driver) {
case 'memcache': case 'memcache':
$cache = new Cache\MemcacheCacheDriver($this->hostname, $this->config); $cache = new Cache\MemcacheCache($this->hostname, $this->config);
break; break;
case 'memcached': case 'memcached':
$cache = new Cache\MemcachedCacheDriver($this->hostname, $this->config, $this->logger); $cache = new Cache\MemcachedCache($this->hostname, $this->config, $this->logger);
break; break;
case 'redis': case 'redis':
$cache = new Cache\RedisCacheDriver($this->hostname, $this->config); $cache = new Cache\RedisCache($this->hostname, $this->config);
break; break;
case 'apcu': case 'apcu':
$cache = new Cache\APCuCache($this->hostname); $cache = new Cache\APCuCache($this->hostname);
break; break;
default: default:
$cache = new Cache\DatabaseCacheDriver($this->hostname, $this->dba); $cache = new Cache\DatabaseCache($this->hostname, $this->dba);
} }
$profiling = $this->config->get('system', 'profiling', false); $profiling = $this->config->get('system', 'profiling', false);

View File

@ -2,8 +2,8 @@
namespace Friendica\Factory; namespace Friendica\Factory;
use Friendica\Core\Cache\ICacheDriver; use Friendica\Core\Cache\ICache;
use Friendica\Core\Cache\IMemoryCacheDriver; use Friendica\Core\Cache\IMemoryCache;
use Friendica\Core\Config\Configuration; use Friendica\Core\Config\Configuration;
use Friendica\Core\Lock; use Friendica\Core\Lock;
use Friendica\Database\Database; use Friendica\Database\Database;
@ -35,7 +35,7 @@ class LockDriverFactory
private $dba; private $dba;
/** /**
* @var ICacheDriver The memory cache driver in case we use it * @var ICache The memory cache driver in case we use it
*/ */
private $cacheDriver; private $cacheDriver;
@ -49,7 +49,7 @@ class LockDriverFactory
*/ */
private $logger; private $logger;
public function __construct(ICacheDriver $cacheDriver, Configuration $config, Database $dba, Profiler $profiler, LoggerInterface $logger) public function __construct(ICache $cacheDriver, Configuration $config, Database $dba, Profiler $profiler, LoggerInterface $logger)
{ {
$this->cacheDriver = $cacheDriver; $this->cacheDriver = $cacheDriver;
$this->config = $config; $this->config = $config;
@ -66,17 +66,17 @@ class LockDriverFactory
case 'memcache': case 'memcache':
case 'memcached': case 'memcached':
case 'redis': case 'redis':
if ($this->cacheDriver instanceof IMemoryCacheDriver) { if ($this->cacheDriver instanceof IMemoryCache) {
return new Lock\CacheLockDriver($this->cacheDriver); return new Lock\CacheLockDriver($this->cacheDriver);
} }
break; break;
case 'database': case 'database':
return new Lock\DatabaseLockDriver($this->dba); return new Lock\DatabaseLock($this->dba);
break; break;
case 'semaphore': case 'semaphore':
return new Lock\SemaphoreLockDriver(); return new Lock\SemaphoreLock();
break; break;
default: default:
@ -96,7 +96,7 @@ class LockDriverFactory
* 2. Cache Locking * 2. Cache Locking
* 3. Database Locking * 3. Database Locking
* *
* @return Lock\ILockDriver * @return Lock\ILock
*/ */
private function useAutoDriver() private function useAutoDriver()
{ {
@ -104,7 +104,7 @@ class LockDriverFactory
// 1. Try to use Semaphores for - local - locking // 1. Try to use Semaphores for - local - locking
if (function_exists('sem_get')) { if (function_exists('sem_get')) {
try { try {
return new Lock\SemaphoreLockDriver(); return new Lock\SemaphoreLock();
} catch (\Exception $exception) { } catch (\Exception $exception) {
$this->logger->debug('Using Semaphore driver for locking failed.', ['exception' => $exception]); $this->logger->debug('Using Semaphore driver for locking failed.', ['exception' => $exception]);
} }
@ -114,7 +114,7 @@ class LockDriverFactory
$cache_driver = $this->config->get('system', 'cache_driver', 'database'); $cache_driver = $this->config->get('system', 'cache_driver', 'database');
if ($cache_driver != 'database') { if ($cache_driver != 'database') {
try { try {
if ($this->cacheDriver instanceof IMemoryCacheDriver) { if ($this->cacheDriver instanceof IMemoryCache) {
return new Lock\CacheLockDriver($this->cacheDriver); return new Lock\CacheLockDriver($this->cacheDriver);
} }
} catch (\Exception $exception) { } catch (\Exception $exception) {
@ -123,6 +123,6 @@ class LockDriverFactory
} }
// 3. Use Database Locking as a Fallback // 3. Use Database Locking as a Fallback
return new Lock\DatabaseLockDriver($this->dba); return new Lock\DatabaseLock($this->dba);
} }
} }

View File

@ -4,7 +4,7 @@ use Dice\Dice;
use Friendica\App; use Friendica\App;
use Friendica\Core\Cache; use Friendica\Core\Cache;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\Lock\ILockDriver; use Friendica\Core\Lock\ILock;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\Factory; use Friendica\Factory;
use Friendica\Util; use Friendica\Util;
@ -106,30 +106,30 @@ return [
* $app = $dice->create(App::class, [], ['$channel' => 'index']); * $app = $dice->create(App::class, [], ['$channel' => 'index']);
* and is automatically passed as an argument with the same name * and is automatically passed as an argument with the same name
*/ */
LoggerInterface::class => [ LoggerInterface::class => [
'instanceOf' => Factory\LoggerFactory::class, 'instanceOf' => Factory\LoggerFactory::class,
'call' => [ 'call' => [
['create', [], Dice::CHAIN_CALL], ['create', [], Dice::CHAIN_CALL],
], ],
], ],
'$devLogger' => [ '$devLogger' => [
'instanceOf' => Factory\LoggerFactory::class, 'instanceOf' => Factory\LoggerFactory::class,
'call' => [ 'call' => [
['createDev', [], Dice::CHAIN_CALL], ['createDev', [], Dice::CHAIN_CALL],
] ]
], ],
Cache\ICacheDriver::class => [ Cache\ICache::class => [
'instanceOf' => Factory\CacheDriverFactory::class, 'instanceOf' => Factory\CacheDriverFactory::class,
'call' => [ 'call' => [
['create', [], Dice::CHAIN_CALL], ['create', [], Dice::CHAIN_CALL],
], ],
], ],
Cache\IMemoryCacheDriver::class => [ Cache\IMemoryCache::class => [
'instanceOf' => Cache\ICacheDriver::class, 'instanceOf' => Cache\ICache::class,
], ],
ILockDriver::class => [ ILock::class => [
'instanceOf' => Factory\LockDriverFactory::class, 'instanceOf' => Factory\LockDriverFactory::class,
'call' => [ 'call' => [
['create', [], Dice::CHAIN_CALL], ['create', [], Dice::CHAIN_CALL],
], ],
], ],

View File

@ -3,7 +3,7 @@
namespace Friendica\Test\Util; namespace Friendica\Test\Util;
use Friendica\Core\Cache; use Friendica\Core\Cache;
use Friendica\Core\Lock\DatabaseLockDriver; use Friendica\Core\Lock\DatabaseLock;
trait DbaLockMockTrait trait DbaLockMockTrait
{ {
@ -12,7 +12,6 @@ trait DbaLockMockTrait
/** /**
* Mocking acquireLock with DBA-backend * Mocking acquireLock with DBA-backend
* @see DatabaseLockDriver::acquireLock()
* *
* @param mixed $key The key to lock * @param mixed $key The key to lock
* @param int $ttl The TimeToLive * @param int $ttl The TimeToLive
@ -22,6 +21,9 @@ trait DbaLockMockTrait
* @param bool $rowExists True, if a row already exists in the lock table * @param bool $rowExists True, if a row already exists in the lock table
* @param null $time The current timestamp * @param null $time The current timestamp
* @param null|int $times How often the method will get used * @param null|int $times How often the method will get used
*
*@see DatabaseLock::acquireLock()
*
*/ */
public function mockAcquireLock($key, $ttl = Cache::FIVE_MINUTES, $locked = false, $pid = null, $rowExists = true, $time = null, $times = null) public function mockAcquireLock($key, $ttl = Cache::FIVE_MINUTES, $locked = false, $pid = null, $rowExists = true, $time = null, $times = null)
{ {
@ -55,12 +57,14 @@ trait DbaLockMockTrait
/** /**
* Mocking isLocked with DBA-backend * Mocking isLocked with DBA-backend
* @see DatabaseLockDriver::isLocked()
* *
* @param mixed $key The key of the lock * @param mixed $key The key of the lock
* @param null|bool $return True, if the key is already locked * @param null|bool $return True, if the key is already locked
* @param null $time The current timestamp * @param null $time The current timestamp
* @param null|int $times How often the method will get used * @param null|int $times How often the method will get used
*
*@see DatabaseLock::isLocked()
*
*/ */
public function mockIsLocked($key, $return = true, $time = null, $times = null) public function mockIsLocked($key, $return = true, $time = null, $times = null)
{ {
@ -76,10 +80,12 @@ trait DbaLockMockTrait
/** /**
* Mocking releaseAll with DBA-backend * Mocking releaseAll with DBA-backend
* @see DatabaseLockDriver::releaseAll()
* *
* @param null $pid The PID which was set * @param null $pid The PID which was set
* @param null|int $times How often the method will get used * @param null|int $times How often the method will get used
*
*@see DatabaseLock::releaseAll()
*
*/ */
public function mockReleaseAll($pid = null, $times = null) public function mockReleaseAll($pid = null, $times = null)
{ {
@ -92,11 +98,13 @@ trait DbaLockMockTrait
/** /**
* Mocking ReleaseLock with DBA-backend * Mocking ReleaseLock with DBA-backend
* @see DatabaseLockDriver::releaseLock()
* *
* @param mixed $key The key to release * @param mixed $key The key to release
* @param null|int $pid The PID which was set * @param null|int $pid The PID which was set
* @param null|int $times How often the method will get used * @param null|int $times How often the method will get used
*
*@see DatabaseLock::releaseLock()
*
*/ */
public function mockReleaseLock($key, $pid = null, $times = null) public function mockReleaseLock($key, $pid = null, $times = null)
{ {

View File

@ -4,7 +4,7 @@ namespace Friendica\Test\src\Core\Cache;
use Friendica\Core\Cache\APCuCache; use Friendica\Core\Cache\APCuCache;
class APCuCacheDriverTest extends MemoryCacheTest class APCuCacheTest extends MemoryCacheTest
{ {
protected function setUp() protected function setUp()
{ {

View File

@ -4,7 +4,7 @@ namespace Friendica\Test\src\Core\Cache;
use Friendica\Core\Cache\ArrayCache; use Friendica\Core\Cache\ArrayCache;
class ArrayCacheDriverTest extends MemoryCacheTest class ArrayCacheTest extends MemoryCacheTest
{ {
protected function getInstance() protected function getInstance()
{ {

View File

@ -2,7 +2,7 @@
namespace Friendica\Test\src\Core\Cache; namespace Friendica\Test\src\Core\Cache;
use Friendica\Core\Cache\MemcachedCacheDriver; use Friendica\Core\Cache\MemcachedCache;
use Friendica\Test\MockedTest; use Friendica\Test\MockedTest;
use Friendica\Util\PidFile; use Friendica\Util\PidFile;
@ -14,12 +14,12 @@ abstract class CacheTest extends MockedTest
protected $startTime = 1417011228; protected $startTime = 1417011228;
/** /**
* @var \Friendica\Core\Cache\ICacheDriver * @var \Friendica\Core\Cache\ICache
*/ */
protected $instance; protected $instance;
/** /**
* @var \Friendica\Core\Cache\IMemoryCacheDriver * @var \Friendica\Core\Cache\IMemoryCache
*/ */
protected $cache; protected $cache;
@ -202,7 +202,7 @@ abstract class CacheTest extends MockedTest
*/ */
public function testGetAllKeys($value1, $value2, $value3) public function testGetAllKeys($value1, $value2, $value3)
{ {
if ($this->cache instanceof MemcachedCacheDriver) { if ($this->cache instanceof MemcachedCache) {
$this->markTestSkipped('Memcached doesn\'t support getAllKeys anymore'); $this->markTestSkipped('Memcached doesn\'t support getAllKeys anymore');
} }

View File

@ -11,7 +11,7 @@ use Friendica\Util\ConfigFileLoader;
use Friendica\Util\Profiler; use Friendica\Util\Profiler;
use Psr\Log\NullLogger; use Psr\Log\NullLogger;
class DatabaseCacheDriverTest extends CacheTest class DatabaseCacheTest extends CacheTest
{ {
use DatabaseTestTrait; use DatabaseTestTrait;
use VFSTrait; use VFSTrait;
@ -36,7 +36,7 @@ class DatabaseCacheDriverTest extends CacheTest
$dba = new StaticDatabase($configCache, $profiler, $logger); $dba = new StaticDatabase($configCache, $profiler, $logger);
$this->cache = new Cache\DatabaseCacheDriver('database', $dba); $this->cache = new Cache\DatabaseCache('database', $dba);
return $this->cache; return $this->cache;
} }

View File

@ -2,13 +2,13 @@
namespace Friendica\Test\src\Core\Cache; namespace Friendica\Test\src\Core\Cache;
use Friendica\Core\Cache\MemcacheCacheDriver; use Friendica\Core\Cache\MemcacheCache;
use Friendica\Core\Config\Configuration; use Friendica\Core\Config\Configuration;
/** /**
* @requires extension memcache * @requires extension memcache
*/ */
class MemcacheCacheDriverTest extends MemoryCacheTest class MemcacheCacheTest extends MemoryCacheTest
{ {
protected function getInstance() protected function getInstance()
{ {
@ -23,7 +23,7 @@ class MemcacheCacheDriverTest extends MemoryCacheTest
->with('system', 'memcache_port') ->with('system', 'memcache_port')
->andReturn(11211); ->andReturn(11211);
$this->cache = new MemcacheCacheDriver('localhost', $configMock); $this->cache = new MemcacheCache('localhost', $configMock);
return $this->cache; return $this->cache;
} }

View File

@ -3,14 +3,14 @@
namespace Friendica\Test\src\Core\Cache; namespace Friendica\Test\src\Core\Cache;
use Friendica\Core\Cache\MemcachedCacheDriver; use Friendica\Core\Cache\MemcachedCache;
use Friendica\Core\Config\Configuration; use Friendica\Core\Config\Configuration;
use Psr\Log\NullLogger; use Psr\Log\NullLogger;
/** /**
* @requires extension memcached * @requires extension memcached
*/ */
class MemcachedCacheDriverTest extends MemoryCacheTest class MemcachedCacheTest extends MemoryCacheTest
{ {
protected function getInstance() protected function getInstance()
{ {
@ -23,7 +23,7 @@ class MemcachedCacheDriverTest extends MemoryCacheTest
$logger = new NullLogger(); $logger = new NullLogger();
$this->cache = new MemcachedCacheDriver('localhost', $configMock, $logger); $this->cache = new MemcachedCache('localhost', $configMock, $logger);
return $this->cache; return $this->cache;
} }

View File

@ -2,12 +2,12 @@
namespace Friendica\Test\src\Core\Cache; namespace Friendica\Test\src\Core\Cache;
use Friendica\Core\Cache\IMemoryCacheDriver; use Friendica\Core\Cache\IMemoryCache;
abstract class MemoryCacheTest extends CacheTest abstract class MemoryCacheTest extends CacheTest
{ {
/** /**
* @var \Friendica\Core\Cache\IMemoryCacheDriver * @var \Friendica\Core\Cache\IMemoryCache
*/ */
protected $instance; protected $instance;
@ -15,7 +15,7 @@ abstract class MemoryCacheTest extends CacheTest
{ {
parent::setUp(); parent::setUp();
if (!($this->instance instanceof IMemoryCacheDriver)) { if (!($this->instance instanceof IMemoryCache)) {
throw new \Exception('MemoryCacheTest unsupported'); throw new \Exception('MemoryCacheTest unsupported');
} }
} }

View File

@ -3,13 +3,13 @@
namespace Friendica\Test\src\Core\Cache; namespace Friendica\Test\src\Core\Cache;
use Friendica\Core\Cache\RedisCacheDriver; use Friendica\Core\Cache\RedisCache;
use Friendica\Core\Config\Configuration; use Friendica\Core\Config\Configuration;
/** /**
* @requires extension redis * @requires extension redis
*/ */
class RedisCacheDriverTest extends MemoryCacheTest class RedisCacheTest extends MemoryCacheTest
{ {
protected function getInstance() protected function getInstance()
{ {
@ -33,7 +33,7 @@ class RedisCacheDriverTest extends MemoryCacheTest
->with('system', 'redis_password') ->with('system', 'redis_password')
->andReturn(null); ->andReturn(null);
$this->cache = new RedisCacheDriver('localhost', $configMock); $this->cache = new RedisCache('localhost', $configMock);
return $this->cache; return $this->cache;
} }

View File

@ -5,7 +5,7 @@ namespace Friendica\Test\src\Core\Lock;
use Friendica\Core\Cache\APCuCache; use Friendica\Core\Cache\APCuCache;
use Friendica\Core\Lock\CacheLockDriver; use Friendica\Core\Lock\CacheLockDriver;
class APCuCacheLockDriverTest extends LockTest class APCuCacheLockTest extends LockTest
{ {
protected function setUp() protected function setUp()
{ {

View File

@ -5,7 +5,7 @@ namespace Friendica\Test\src\Core\Lock;
use Friendica\Core\Cache\ArrayCache; use Friendica\Core\Cache\ArrayCache;
use Friendica\Core\Lock\CacheLockDriver; use Friendica\Core\Lock\CacheLockDriver;
class ArrayCacheLockDriverTest extends LockTest class ArrayCacheLockTest extends LockTest
{ {
protected function getInstance() protected function getInstance()
{ {

View File

@ -2,7 +2,7 @@
namespace Friendica\Test\src\Core\Lock; namespace Friendica\Test\src\Core\Lock;
use Friendica\Core\Lock\DatabaseLockDriver; use Friendica\Core\Lock\DatabaseLock;
use Friendica\Factory\ConfigFactory; use Friendica\Factory\ConfigFactory;
use Friendica\Test\DatabaseTestTrait; use Friendica\Test\DatabaseTestTrait;
use Friendica\Test\Util\Database\StaticDatabase; use Friendica\Test\Util\Database\StaticDatabase;
@ -38,6 +38,6 @@ class DatabaseLockDriverTest extends LockTest
$dba = new StaticDatabase($configCache, $profiler, $logger); $dba = new StaticDatabase($configCache, $profiler, $logger);
return new DatabaseLockDriver($dba, $this->pid); return new DatabaseLock($dba, $this->pid);
} }
} }

View File

@ -12,7 +12,7 @@ abstract class LockTest extends MockedTest
protected $startTime = 1417011228; protected $startTime = 1417011228;
/** /**
* @var \Friendica\Core\Lock\ILockDriver * @var \Friendica\Core\Lock\ILock
*/ */
protected $instance; protected $instance;

View File

@ -3,14 +3,14 @@
namespace Friendica\Test\src\Core\Lock; namespace Friendica\Test\src\Core\Lock;
use Friendica\Core\Cache\MemcacheCacheDriver; use Friendica\Core\Cache\MemcacheCache;
use Friendica\Core\Config\Configuration; use Friendica\Core\Config\Configuration;
use Friendica\Core\Lock\CacheLockDriver; use Friendica\Core\Lock\CacheLockDriver;
/** /**
* @requires extension Memcache * @requires extension Memcache
*/ */
class MemcacheCacheLockDriverTest extends LockTest class MemcacheCacheLockTest extends LockTest
{ {
protected function getInstance() protected function getInstance()
{ {
@ -25,6 +25,6 @@ class MemcacheCacheLockDriverTest extends LockTest
->with('system', 'memcache_port') ->with('system', 'memcache_port')
->andReturn(11211); ->andReturn(11211);
return new CacheLockDriver(new MemcacheCacheDriver('localhost', $configMock)); return new CacheLockDriver(new MemcacheCache('localhost', $configMock));
} }
} }

View File

@ -3,7 +3,7 @@
namespace Friendica\Test\src\Core\Lock; namespace Friendica\Test\src\Core\Lock;
use Friendica\Core\Cache\MemcachedCacheDriver; use Friendica\Core\Cache\MemcachedCache;
use Friendica\Core\Config\Configuration; use Friendica\Core\Config\Configuration;
use Friendica\Core\Lock\CacheLockDriver; use Friendica\Core\Lock\CacheLockDriver;
use Psr\Log\NullLogger; use Psr\Log\NullLogger;
@ -11,7 +11,7 @@ use Psr\Log\NullLogger;
/** /**
* @requires extension memcached * @requires extension memcached
*/ */
class MemcachedCacheLockDriverTest extends LockTest class MemcachedCacheLockTest extends LockTest
{ {
protected function getInstance() protected function getInstance()
{ {
@ -24,6 +24,6 @@ class MemcachedCacheLockDriverTest extends LockTest
$logger = new NullLogger(); $logger = new NullLogger();
return new CacheLockDriver(new MemcachedCacheDriver('localhost', $configMock, $logger)); return new CacheLockDriver(new MemcachedCache('localhost', $configMock, $logger));
} }
} }

View File

@ -3,14 +3,14 @@
namespace Friendica\Test\src\Core\Lock; namespace Friendica\Test\src\Core\Lock;
use Friendica\Core\Cache\RedisCacheDriver; use Friendica\Core\Cache\RedisCache;
use Friendica\Core\Config\Configuration; use Friendica\Core\Config\Configuration;
use Friendica\Core\Lock\CacheLockDriver; use Friendica\Core\Lock\CacheLockDriver;
/** /**
* @requires extension redis * @requires extension redis
*/ */
class RedisCacheLockDriverTest extends LockTest class RedisCacheLockTest extends LockTest
{ {
protected function getInstance() protected function getInstance()
{ {
@ -34,6 +34,6 @@ class RedisCacheLockDriverTest extends LockTest
->with('system', 'redis_password') ->with('system', 'redis_password')
->andReturn(null); ->andReturn(null);
return new CacheLockDriver(new RedisCacheDriver('localhost', $configMock)); return new CacheLockDriver(new RedisCache('localhost', $configMock));
} }
} }

View File

@ -6,9 +6,9 @@ use Dice\Dice;
use Friendica\App; use Friendica\App;
use Friendica\BaseObject; use Friendica\BaseObject;
use Friendica\Core\Config\Configuration; use Friendica\Core\Config\Configuration;
use Friendica\Core\Lock\SemaphoreLockDriver; use Friendica\Core\Lock\SemaphoreLock;
class SemaphoreLockDriverTest extends LockTest class SemaphoreLockTest extends LockTest
{ {
public function setUp() public function setUp()
{ {
@ -33,7 +33,7 @@ class SemaphoreLockDriverTest extends LockTest
protected function getInstance() protected function getInstance()
{ {
return new SemaphoreLockDriver(); return new SemaphoreLock();
} }
function testLockTTL() function testLockTTL()