1 <?php
2 /**
3 * Neevo - Tiny database layer for PHP. (http://neevo.smasty.net)
4 *
5 * This source file is subject to the MIT license that is bundled
6 * with this package in the file license.txt.
7 *
8 * Copyright (c) 2012 Smasty (http://smasty.net)
9 *
10 */
11
12 namespace Neevo\Cache;
13
14 use Memcache;
15
16
17 /**
18 * Memcache cache storage.
19 * @author Smasty
20 */
21 class MemcacheStorage implements StorageInterface {
22
23
24 /** @var Memcache */
25 private $memcache;
26
27
28 public function __construct(Memcache $memcache){
29 $this->memcache = $memcache;
30 }
31
32
33 public function fetch($key){
34 $value = $this->memcache->get("NeevoCache.$key");
35 return $value !== false ? $value : null;
36 }
37
38
39 public function store($key, $value){
40 $this->memcache->set("NeevoCache.$key", $value);
41 }
42
43
44 public function flush(){
45 return $this->memcache->flush();
46 }
47
48
49 }
50