X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=app%2FGithub%2FStorage%2FRedis.php;h=c6db525091c7d1fe1360906382a8ea875aeb3a8b;hb=5c1a4c8a5d83ea925f17c94e5ab996b92e31e240;hp=c971687aa1b0e44f2e4ed811abe6d527635db935;hpb=b9ea42b0b88f4976327ed03a1e4abb9b34248b7a;p=pharext%2Fpharext.org diff --git a/app/Github/Storage/Redis.php b/app/Github/Storage/Redis.php index c971687..c6db525 100644 --- a/app/Github/Storage/Redis.php +++ b/app/Github/Storage/Redis.php @@ -15,16 +15,13 @@ class Redis implements Storage $rd = new \Redis(); $rd->open("localhost"); $rd->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP); + $rd->setOption(\Redis::OPT_PREFIX, "$ns:"); } $this->rd = $rd; } - private function key($key) { - return sprintf("%s:%s", $this->ns, $key); - } - function get($key, Item &$item = null, $update = false) { - if (!$item = $this->rd->get($this->key($key))) { + if (!$item = $this->rd->get($key)) { return false; } @@ -34,7 +31,7 @@ class Redis implements Storage if ($item->getLTL() >= 0) { if ($update) { $item->setTimestamp(); - $this->rd->setex($this->key($key), $item->getTTL() + 60*60*24, $item); + $this->rd->setex($key, $item->getTTL() + 60*60*24, $item); } return true; } @@ -43,14 +40,14 @@ class Redis implements Storage function set($key, Item $item) { if (null === $item->getTTL()) { - $this->rd->set($this->key($key), $item); + $this->rd->set($key, $item); } else { - $this->rd->setex($this->key($key), $item->getTTL() + 60*60*24, $item); + $this->rd->setex($key, $item->getTTL() + 60*60*24, $item); } return $this; } function del($key) { - $this->rd->delete($this->key($key)); + $this->rd->delete($key); } }