Skip to content

Commit b9f8f40

Browse files
committed
ReadOnlyPeer can use any instance of CachePeer childs
1 parent 9a858b0 commit b9f8f40

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

core/Cache/ReadOnlyPeer.class.php

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,48 @@
1010
***************************************************************************/
1111

1212
/**
13-
* Memcached-based cache with read-only access.
13+
* Cache with read-only access.
1414
*
1515
* @ingroup Cache
1616
**/
17-
final class ReadOnlyPeer extends PeclMemcached
17+
final class ReadOnlyPeer extends CachePeer
1818
{
19+
/**
20+
* @var CachePeer
21+
*/
22+
private $innerPeer = null;
23+
1924
/**
2025
* @return ReadOnlyPeer
2126
*/
22-
public static function create(
23-
$host = Memcached::DEFAULT_HOST,
24-
$port = Memcached::DEFAULT_PORT,
25-
$buffer = Memcached::DEFAULT_BUFFER
26-
)
27+
public static function create(CachePeer $peer)
28+
{
29+
return new ReadOnlyPeer($peer);
30+
}
31+
32+
public function __construct(CachePeer $peer)
33+
{
34+
$this->innerPeer = $peer;
35+
}
36+
37+
public function isAlive()
38+
{
39+
return $this->innerPeer->isAlive();
40+
}
41+
42+
public function mark($className)
43+
{
44+
return $this->innerPeer->mark($className);
45+
}
46+
47+
public function get($key)
48+
{
49+
return $this->innerPeer->get($key);
50+
}
51+
52+
public function getList($indexes)
2753
{
28-
return new ReadOnlyPeer($host, $port, $buffer);
54+
return $this->innerPeer->getList($indexes);
2955
}
3056

3157
public function clean()

0 commit comments

Comments
 (0)