3 namespace app\Github\Storage
;
5 use app\Github\Storage
;
7 class Memcache
implements Storage
12 function __construct($ns = "github", \Memcached
$mc = null) {
15 $mc = new \
Memcached("pharext");
16 $mc->addServer("localhost", 11211);
17 $mc->setOption(\Memcached
::OPT_PREFIX_KEY
, "$ns:");
22 function get($key, Item
&$item = null, $update = false) {
23 if (!$item = $this->mc
->get($key)) {
27 if (null === $item->getTTL()) {
30 if ($item->getLTL() >= 0) {
32 $item->setTimestamp();
33 $this->mc
->set($key, $item, $item->getTTL() +
60*60*24);
40 function set($key, Item
$item) {
41 $this->mc
->set($key, $item, (null !== $item->getTTL()) ?
$item->getTTL() +
60*60*24 : 0);
46 $this->mc
->delete($key);