Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

string prefix for keys added

  • Loading branch information...
commit 5972e311ca9cc985e6e3f8c492a3fbd1f46ec6b2 1 parent 1ba627d
@ebaioni ebaioni authored
Showing with 8 additions and 2 deletions.
  1. +6 −1 Client/MemcacheClient.php
  2. +2 −1  Resources/config/services.yml
View
7 Client/MemcacheClient.php
@@ -20,15 +20,17 @@ class MemcacheClient implements CacheClientInterface
protected $servers = array();
protected $sockttl = 0.2;
protected $compression = false;
+ protected $prefix = '';
/**
* Constructs the cache client using an injected Memcache instance
*
* @access public
*/
- public function __construct(\Memcache $memcache)
+ public function __construct(\Memcache $memcache, $prefix)
{
$this->mem = $memcache;
+ $this->prefix = $prefix;
}
/**
@@ -123,6 +125,7 @@ public function probeServer($ip, $port)
public function get($key)
{
if ($this->isSafe()) {
+ $key = $this->prefix . $key;
return $this->mem->get($key);
}
@@ -141,6 +144,7 @@ public function get($key)
public function set($key, $value, $ttl)
{
if ($this->isSafe()) {
+ $key = $this->prefix . $key;
return $this->mem->set($key, $value, $this->compression, $ttl);
}
@@ -157,6 +161,7 @@ public function set($key, $value, $ttl)
public function delete($key)
{
if ($this->isSafe()) {
+ $key = $this->prefix . $key;
return $this->mem->delete($key, 0);
}
View
3  Resources/config/services.yml
@@ -3,13 +3,14 @@ parameters:
beryllium_cache.client.class: Beryllium\CacheBundle\Client\MemcacheClient
beryllium_cache.client.memcache.class: Memcache
beryllium_cache.client.servers: { 127.0.0.1 : 11211 }
+ beryllium_cache.client.prefix: ''
services:
beryllium_cache.client.memcache:
class: %beryllium_cache.client.memcache.class%
beryllium_cache.client:
class: %beryllium_cache.client.class%
- arguments: [@beryllium_cache.client.memcache]
+ arguments: [@beryllium_cache.client.memcache, %beryllium_cache.client.prefix%]
calls:
- [ addServers, [ %beryllium_cache.client.servers% ] ]
beryllium_cache:
Please sign in to comment.
Something went wrong with that request. Please try again.