| @@ 9-41 (lines=33) @@ | ||
| 6 | use Metaphore\Store\AbstractMemcachedStore; |
|
| 7 | use Memcached; |
|
| 8 | ||
| 9 | class MemcachedStore extends AbstractMemcachedStore implements ValueStoreInterface, LockStoreInterface |
|
| 10 | { |
|
| 11 | /*** @var Memcached */ |
|
| 12 | protected $memcached; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * @param Memcached |
|
| 16 | */ |
|
| 17 | public function __construct(Memcached $memcached) |
|
| 18 | { |
|
| 19 | $this->memcached = $memcached; |
|
| 20 | } |
|
| 21 | ||
| 22 | public function set($key, $value, $ttl) |
|
| 23 | { |
|
| 24 | return $this->memcached->set($this->prepareKey($key), $value, $this->prepareTtl($ttl)); |
|
| 25 | } |
|
| 26 | ||
| 27 | public function get($key) |
|
| 28 | { |
|
| 29 | return $this->memcached->get($this->prepareKey($key)); |
|
| 30 | } |
|
| 31 | ||
| 32 | public function add($key, $value, $ttl) |
|
| 33 | { |
|
| 34 | return $this->memcached->add($this->prepareKey($key), $value, $this->prepareTtl($ttl)); |
|
| 35 | } |
|
| 36 | ||
| 37 | public function delete($key) |
|
| 38 | { |
|
| 39 | return $this->memcached->delete($this->prepareKey($key)); |
|
| 40 | } |
|
| 41 | } |
|
| 42 | ||
| @@ 9-41 (lines=33) @@ | ||
| 6 | use Metaphore\Store\AbstractMemcachedStore; |
|
| 7 | use Memcache; |
|
| 8 | ||
| 9 | class MemcacheStore extends AbstractMemcachedStore implements ValueStoreInterface, LockStoreInterface |
|
| 10 | { |
|
| 11 | /*** @var Memcache */ |
|
| 12 | protected $memcache; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * @param Memcache |
|
| 16 | */ |
|
| 17 | public function __construct(Memcache $memcache) |
|
| 18 | { |
|
| 19 | $this->memcache = $memcache; |
|
| 20 | } |
|
| 21 | ||
| 22 | public function set($key, $value, $ttl) |
|
| 23 | { |
|
| 24 | return $this->memcache->set($this->prepareKey($key), $value, 0, $this->prepareTtl($ttl)); |
|
| 25 | } |
|
| 26 | ||
| 27 | public function get($key) |
|
| 28 | { |
|
| 29 | return $this->memcache->get($this->prepareKey($key)); |
|
| 30 | } |
|
| 31 | ||
| 32 | public function add($key, $value, $ttl) |
|
| 33 | { |
|
| 34 | return $this->memcache->add($this->prepareKey($key), $value, 0, $this->prepareTtl($ttl)); |
|
| 35 | } |
|
| 36 | ||
| 37 | public function delete($key) |
|
| 38 | { |
|
| 39 | return $this->memcache->delete($this->prepareKey($key)); |
|
| 40 | } |
|
| 41 | } |
|
| 42 | ||