From 7cdc6dd45793962a994f2995e62cc744332172e4 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 26 Oct 2017 20:04:08 +0200 Subject: [PATCH] Added dummy memcached --- DataStorage/Cache/MemCache.php | 2 +- DataStorage/Cache/MemCached.php | 178 ++++++++++++++++++++++++++++++++ 2 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 DataStorage/Cache/MemCached.php diff --git a/DataStorage/Cache/MemCache.php b/DataStorage/Cache/MemCache.php index 4314263af..9774158da 100644 --- a/DataStorage/Cache/MemCache.php +++ b/DataStorage/Cache/MemCache.php @@ -50,7 +50,7 @@ class MemCache implements CacheInterface */ public function __construct() { - $this->memc = new self(); + $this->memc = null; } /** diff --git a/DataStorage/Cache/MemCached.php b/DataStorage/Cache/MemCached.php new file mode 100644 index 000000000..040dbfb9f --- /dev/null +++ b/DataStorage/Cache/MemCached.php @@ -0,0 +1,178 @@ +memc = null; + } + + /** + * Adding server to server pool. + * + * @param mixed $data Server data array + * + * @return void + * + * @since 1.0.0 + */ + public function addServer($data) + { + $this->memc->addServer($data['host'], $data['port'], $data['timeout']); + } + + /** + * {@inheritdoc} + */ + public function set($key, $value, int $expire = -1) /* : void */ + { + $this->memc->set($key, $value, false, $expire); + } + + /** + * {@inheritdoc} + */ + public function add($key, $value, int $expire = -1) : bool + { + return $this->memc->add($key, $value, false, $expire); + } + + /** + * {@inheritdoc} + */ + public function get($key, int $expire = -1) + { + return $this->memc->get($key); + } + + /** + * {@inheritdoc} + */ + public function delete($key, int $expire = -1) : bool + { + $this->memc->delete($key); + } + + /** + * {@inheritdoc} + */ + public function flush(int $expire = 0) : bool + { + $this->memc->flush(); + + return true; + } + + /** + * {@inheritdoc} + */ + public function flushAll() : bool + { + $this->memc->flush(); + + return true; + } + + /** + * {@inheritdoc} + */ + public function replace($key, $value, int $expire = -1) : bool + { + $this->memc->replace($key, $value, false, $expire); + } + + /** + * {@inheritdoc} + */ + public function stats() : array + { + /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */ + return $this->memc->getExtendedStats(); + } + + /** + * {@inheritdoc} + */ + public function getThreshold() : int + { + return $this->threshold; + } + + /** + * {@inheritdoc} + */ + public function setStatus(int $status) /* : void */ + { + $this->status = $status; + } + + /** + * Destructor. + * + * @since 1.0.0 + */ + public function __destruct() + { + $this->close(); + } + + /** + * Closing cache. + * + * @since 1.0.0 + */ + public function close() + { + if ($this->memc !== null) { + $this->memc->close(); + $this->memc = null; + } + } + +}