X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=app%2FGithub%2FStorage%2FMemcache.php;h=5e4959b9bc0c028c6523f05e0288e6a4e5fd0e9d;hb=5c1a4c8a5d83ea925f17c94e5ab996b92e31e240;hp=452574b9dbb9f4dfec9b9516bb0003eb2b83e6b5;hpb=b9ea42b0b88f4976327ed03a1e4abb9b34248b7a;p=pharext%2Fpharext.org diff --git a/app/Github/Storage/Memcache.php b/app/Github/Storage/Memcache.php index 452574b..5e4959b 100644 --- a/app/Github/Storage/Memcache.php +++ b/app/Github/Storage/Memcache.php @@ -14,16 +14,13 @@ class Memcache implements Storage if (!$mc) { $mc = new \Memcached("pharext"); $mc->addServer("localhost", 11211); + $mc->setOption(\Memcached::OPT_PREFIX_KEY, "$ns:"); } $this->mc = $mc; } - private function key($key) { - return sprintf("%s:%s", $this->ns, $key); - } - function get($key, Item &$item = null, $update = false) { - if (!$item = $this->mc->get($this->key($key))) { + if (!$item = $this->mc->get($key)) { return false; } @@ -33,7 +30,7 @@ class Memcache implements Storage if ($item->getLTL() >= 0) { if ($update) { $item->setTimestamp(); - $this->mc->set($this->key($key), $item, $item->getTTL() + 60*60*24); + $this->mc->set($key, $item, $item->getTTL() + 60*60*24); } return true; } @@ -41,11 +38,11 @@ class Memcache implements Storage } function set($key, Item $item) { - $this->mc->set($this->key($key), $item, (null !== $item->getTTL()) ? $item->getTTL() + 60*60*24 : 0); + $this->mc->set($key, $item, (null !== $item->getTTL()) ? $item->getTTL() + 60*60*24 : 0); return $this; } function del($key) { - $this->mc->delete($this->key($key)); + $this->mc->delete($key); } }