Refactor Cache/Lock to DICE

- Refactor Cache classes
- Refactor Lock classes
- Improved test speed (removed some seperate class annotations)
This commit is contained in:
Philipp Holzer 2019-08-03 20:48:56 +02:00
parent b95d4f41b9
commit d56bd28a07
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
40 changed files with 766 additions and 621 deletions

View file

@ -2,9 +2,9 @@
namespace Friendica\Core\Cache;
use Friendica\Core\Cache;
use Exception;
use Friendica\Core\Cache;
use Friendica\Core\Config\Configuration;
use Memcache;
/**
@ -23,18 +23,21 @@ class MemcacheCacheDriver extends AbstractCacheDriver implements IMemoryCacheDri
private $memcache;
/**
* @param string $memcache_host
* @param int $memcache_port
* @throws Exception
*/
public function __construct($memcache_host, $memcache_port)
public function __construct(string $hostname, Configuration $config)
{
if (!class_exists('Memcache', false)) {
throw new Exception('Memcache class isn\'t available');
}
parent::__construct($hostname);
$this->memcache = new Memcache();
$memcache_host = $config->get('system', 'memcache_host');
$memcache_port = $config->get('system', 'memcache_port');
if (!$this->memcache->connect($memcache_host, $memcache_port)) {
throw new Exception('Expected Memcache server at ' . $memcache_host . ':' . $memcache_port . ' isn\'t available');
}