-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathPool.php
More file actions
91 lines (80 loc) · 2.67 KB
/
Pool.php
File metadata and controls
91 lines (80 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
namespace SplitIO\Component\Cache;
use SplitIO\Component\Cache\Storage\Adapter\PRedis as PRedisAdapter;
use SplitIO\Component\Cache\Storage\Adapter\SafeRedisWrapper;
use SplitIO\Component\Common\Context;
class Pool extends CacheKeyTrait
{
/** @var null|\SplitIO\Component\Cache\Storage\Adapter\CacheStorageAdapterInterface */
private $adapter = null;
/**
* @param array $options
*/
public function __construct(array $options = array())
{
$adapterOptions = (isset($options['adapter']['options'])
&& is_array($options['adapter']['options'])) ? $options['adapter']['options'] : array();
$this->adapter = new SafeRedisWrapper(new PredisAdapter($adapterOptions));
}
/**
* Returns a Cache Item representing the specified key.
*
* This method must always return a CacheItemInterface object, even in case of
* a cache miss. It MUST NOT return null.
*
* @param string $key
* The key for which to return the corresponding Cache Item.
*
* @throws \InvalidArgumentException
* If the $key string is not a legal value a \Psr\Cache\InvalidArgumentException
* MUST be thrown.
*
* @return string
*/
public function get($key)
{
$this->assertValidKey($key);
Context::getLogger()->debug("Fetching item ** $key ** from cache");
return $this->adapter->get($key);
}
/**
* Returns a traversable set of cache items.
*
* @param array $keys
* An indexed array of keys of items to retrieve.
*
* @throws \InvalidArgumentException
* If any of the keys in $keys are not a legal value a \Psr\Cache\InvalidArgumentException
* MUST be thrown.
*
* @return array|\Traversable
* A traversable collection of Cache Items keyed by the cache keys of
* each item. A Cache item will be returned for each key, even if that
* key is not found. However, if no keys are specified then an empty
* traversable MUST be returned instead.
*/
public function fetchMany(array $keys = array())
{
return $this->adapter->fetchMany($keys);
}
public function isItemOnList($key, $value)
{
return $this->adapter->isOnList($key, $value);
}
public function getKeys($pattern = '*')
{
return $this->adapter->getKeys($pattern);
}
public function rightPushInList($queue, $item)
{
return $this->adapter->rightPushQueue($queue, $item);
}
public function expireKey($key, $ttl)
{
return $this->adapter->expireKey($key, $ttl);
}
public function sMembers($key)
{
return $this->adapter->sMembers($key);
}
}