1 <?php
2
3 /*
4 * This file is part of the ICanBoogie package.
5 *
6 * (c) Olivier Laviale <olivier.laviale@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace ICanBoogie;
13
14 interface StorageInterface
15 {
16 public function store($key, $data, $ttl=0)
17 {
18
19 }
20
21 public function retrieve($key)
22 {
23
24 }
25
26 public function eliminate($key)
27 {
28
29 }
30 }
31
32 class Cache implements StorageInterface
33 {
34 private $master_key;
35
36 public function __construct()
37 {
38 $this->master_key = md5($_SERVER['DOCUMENT_ROOT']);
39 }
40
41 public function store($key, $data, $ttl=0)
42 {
43 apc_store($key, $data, $ttl);
44 }
45
46 public function retrieve($key)
47 {
48 $rc = apc_fetch($key, $success);
49
50 return $success ? $rc : null;
51 }
52 }