1 | <?php |
||
9 | class CFileCache |
||
10 | { |
||
11 | use \Anax\TConfigure; |
||
12 | |||
13 | |||
14 | |||
15 | /** |
||
16 | * Create a key to use for the cache. |
||
17 | * |
||
18 | * @param string $class name of the class, including |
||
19 | * namespace. |
||
20 | * @param string $id unique id for item in each class. |
||
21 | * |
||
22 | * @return string the filename. |
||
23 | */ |
||
24 | public function createKey($class, $id) |
||
28 | |||
29 | |||
30 | |||
31 | /** |
||
32 | * Generate a filename for the cached object. |
||
33 | * |
||
34 | * @param string $key to the cached object. |
||
35 | * |
||
36 | * @return string the filename. |
||
37 | */ |
||
38 | public function filename($key) |
||
42 | |||
43 | |||
44 | |||
45 | /** |
||
46 | * Get an item from the cache if available. |
||
47 | * |
||
48 | * @param string $key to the cached object. |
||
49 | * @param boolean $age check the age or not, defaults to |
||
50 | * false. |
||
51 | * |
||
52 | * @return mixed the cached object or false if it has aged |
||
53 | * or null if it does not exists. |
||
54 | */ |
||
55 | public function get($key, $age = false) |
||
73 | |||
74 | |||
75 | |||
76 | /** |
||
77 | * Put an item to the cache. |
||
78 | * |
||
79 | * @param string $key to the cached object. |
||
80 | * @param mixed $item the object to be cached. |
||
81 | * |
||
82 | * @throws Exception if failing to write to cache. |
||
83 | * |
||
84 | * @return void |
||
85 | */ |
||
86 | public function put($key, $item) |
||
100 | |||
101 | |||
102 | |||
103 | /** |
||
104 | * Prune a item from cache. |
||
105 | * |
||
106 | * @param string $key to the cached object. |
||
107 | * |
||
108 | * @return void |
||
109 | */ |
||
110 | public function prune($key) |
||
114 | |||
115 | |||
116 | |||
117 | /** |
||
118 | * Prune all items from cache. |
||
119 | * |
||
120 | * @return int number of items removed. |
||
121 | */ |
||
122 | public function pruneAll() |
||
129 | } |
||
130 |
If you suppress an error, we recommend checking for the error condition explicitly: