memcache.patch
| Memcache.php (working copy) | ||
|---|---|---|
| 14 | 14 |
// Cache backend object and flags |
| 15 | 15 |
protected $backend; |
| 16 | 16 |
protected $flags; |
| 17 |
|
|
| 18 |
private $namespace; |
|
| 17 | 19 | |
| 18 | 20 |
public function __construct() |
| 19 | 21 |
{
|
| ... | ... | |
| 23 | 25 |
$this->backend = new Memcache; |
| 24 | 26 |
$this->flags = Kohana::config('cache_memcache.compression') ? MEMCACHE_COMPRESSED : 0;
|
| 25 | 27 | |
| 28 |
$this->namespace = Kohana::config('cache_memcache.app_namespace') ? Kohana::config('cache_memcache.app_namespace') : "";
|
|
| 29 | ||
| 26 | 30 |
$servers = Kohana::config('cache_memcache.servers');
|
| 27 | 31 | |
| 28 | 32 |
foreach ($servers as $server) |
| ... | ... | |
| 43 | 47 | |
| 44 | 48 |
public function get($id) |
| 45 | 49 |
{
|
| 46 |
return (($return = $this->backend->get($id)) === FALSE) ? NULL : $return; |
|
| 50 |
return (($return = $this->backend->get($this->namespace.$id)) === FALSE) ? NULL : $return;
|
|
| 47 | 51 |
} |
| 48 | 52 | |
| 49 | 53 |
public function set($id, $data, $tags, $lifetime) |
| ... | ... | |
| 56 | 60 |
$lifetime += time(); |
| 57 | 61 |
} |
| 58 | 62 | |
| 59 |
return $this->backend->set($id, $data, $this->flags, $lifetime); |
|
| 63 |
return $this->backend->set($this->namespace.$id, $data, $this->flags, $lifetime);
|
|
| 60 | 64 |
} |
| 61 | 65 | |
| 62 | 66 |
public function delete($id, $tag = FALSE) |
| ... | ... | |
| 65 | 69 |
return $this->backend->flush(); |
| 66 | 70 | |
| 67 | 71 |
if ($tag == FALSE) |
| 68 |
return $this->backend->delete($id); |
|
| 72 |
return $this->backend->delete($this->namespace.$id);
|
|
| 69 | 73 | |
| 70 | 74 |
return TRUE; |
| 71 | 75 |
} |
| cache_memcache.php (working copy) | ||
|---|---|---|
| 18 | 18 |
* Enable cache data compression. |
| 19 | 19 |
*/ |
| 20 | 20 |
$config['compression'] = FALSE; |
| 21 | ||
| 22 | ||
| 23 |
/** |
|
| 24 |
* Application cache variable namespace |
|
| 25 |
* @var String |
|
| 26 |
*/ |
|
| 27 |
$config['app_namespace'] = FALSE |
|