From c1988e3250e8f3d1228327c4c6488493bdd95d44 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klestov" Date: Tue, 27 Dec 2011 17:21:01 +0400 Subject: [PATCH 1/4] read only cache peer based on Memcached --- core/Cache/ReadOnlyPeer.class.php | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 core/Cache/ReadOnlyPeer.class.php diff --git a/core/Cache/ReadOnlyPeer.class.php b/core/Cache/ReadOnlyPeer.class.php new file mode 100644 index 0000000000..686f549b6d --- /dev/null +++ b/core/Cache/ReadOnlyPeer.class.php @@ -0,0 +1,51 @@ + From 5814633e5bba582dff9478049e0ebeb9dfdc8e07 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klestov" Date: Thu, 19 Jan 2012 14:48:56 +0400 Subject: [PATCH 2/4] add create method for ReadOnlyPeer --- core/Cache/ReadOnlyPeer.class.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/Cache/ReadOnlyPeer.class.php b/core/Cache/ReadOnlyPeer.class.php index 686f549b6d..7bdb5d0d8b 100644 --- a/core/Cache/ReadOnlyPeer.class.php +++ b/core/Cache/ReadOnlyPeer.class.php @@ -16,6 +16,18 @@ **/ final class ReadOnlyPeer extends Memcached { + /** + * @return ReadOnlyPeer + */ + public static function create( + $host = Memcached::DEFAULT_HOST, + $port = Memcached::DEFAULT_PORT, + $buffer = Memcached::DEFAULT_BUFFER + ) + { + return new ReadOnlyPeer($host, $port, $buffer); + } + public function clean() { throw new UnsupportedMethodException(); From 9a858b0db6d6f9de832c7cd189a1803138c543e8 Mon Sep 17 00:00:00 2001 From: "Evgeniy V. Kokovikhin" Date: Tue, 24 Jan 2012 12:19:22 +0400 Subject: [PATCH 3/4] I want to use another exception --- core/Cache/ReadOnlyPeer.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Cache/ReadOnlyPeer.class.php b/core/Cache/ReadOnlyPeer.class.php index 7bdb5d0d8b..8437ad2ff2 100644 --- a/core/Cache/ReadOnlyPeer.class.php +++ b/core/Cache/ReadOnlyPeer.class.php @@ -14,7 +14,7 @@ * * @ingroup Cache **/ - final class ReadOnlyPeer extends Memcached + final class ReadOnlyPeer extends PeclMemcached { /** * @return ReadOnlyPeer From b9f8f40d83acb5b6a240a5a3c0e9f6f3afb04e41 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klestov" Date: Fri, 27 Jan 2012 13:27:08 +0400 Subject: [PATCH 4/4] ReadOnlyPeer can use any instance of CachePeer childs --- core/Cache/ReadOnlyPeer.class.php | 42 +++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/core/Cache/ReadOnlyPeer.class.php b/core/Cache/ReadOnlyPeer.class.php index 8437ad2ff2..90cbc148fe 100644 --- a/core/Cache/ReadOnlyPeer.class.php +++ b/core/Cache/ReadOnlyPeer.class.php @@ -10,22 +10,48 @@ ***************************************************************************/ /** - * Memcached-based cache with read-only access. + * Cache with read-only access. * * @ingroup Cache **/ - final class ReadOnlyPeer extends PeclMemcached + final class ReadOnlyPeer extends CachePeer { + /** + * @var CachePeer + */ + private $innerPeer = null; + /** * @return ReadOnlyPeer */ - public static function create( - $host = Memcached::DEFAULT_HOST, - $port = Memcached::DEFAULT_PORT, - $buffer = Memcached::DEFAULT_BUFFER - ) + public static function create(CachePeer $peer) + { + return new ReadOnlyPeer($peer); + } + + public function __construct(CachePeer $peer) + { + $this->innerPeer = $peer; + } + + public function isAlive() + { + return $this->innerPeer->isAlive(); + } + + public function mark($className) + { + return $this->innerPeer->mark($className); + } + + public function get($key) + { + return $this->innerPeer->get($key); + } + + public function getList($indexes) { - return new ReadOnlyPeer($host, $port, $buffer); + return $this->innerPeer->getList($indexes); } public function clean()