1 | <?php |
||
12 | class FileStorage extends AbstractStorage implements StorageInterface { |
||
13 | |||
14 | /** |
||
15 | * Cache file extension |
||
16 | * @var int |
||
17 | */ |
||
18 | protected $extension = 'kcf'; |
||
19 | |||
20 | /** |
||
21 | * Cache file locking |
||
22 | * @var bool |
||
23 | */ |
||
24 | protected $fileLocking = true; |
||
25 | |||
26 | /** |
||
27 | * Cache directory |
||
28 | * @var type |
||
29 | */ |
||
30 | protected $cacheDir; |
||
31 | |||
32 | /** |
||
33 | * Constructor |
||
34 | * |
||
35 | * @param array $options |
||
36 | */ |
||
37 | public function __construct(array $options = array()) { |
||
51 | |||
52 | /** |
||
53 | * Initialise Cache storage |
||
54 | * |
||
55 | * @return boolean |
||
56 | * |
||
57 | * @throws \Kemist\Cache\Exception |
||
58 | */ |
||
59 | public function init() { |
||
65 | |||
66 | /** |
||
67 | * Checks if the specified name in cache exists |
||
68 | * |
||
69 | * @param string $name cache name |
||
70 | * |
||
71 | * @return bool |
||
72 | */ |
||
73 | public function has($name) { |
||
76 | |||
77 | /** |
||
78 | * Deletes the specified cache or each one if '' given |
||
79 | * |
||
80 | * @param string $name cache name |
||
81 | * |
||
82 | * @return bool |
||
83 | */ |
||
84 | public function delete($name = '') { |
||
97 | |||
98 | /** |
||
99 | * Saves the variable to the $name cache |
||
100 | * |
||
101 | * @param string $name cache name |
||
102 | * @param mixed $val variable to be stored |
||
103 | * @param bool $compressed Compress value with gz |
||
104 | * |
||
105 | * @return bool |
||
106 | */ |
||
107 | public function store($name, $val, $compressed = false) { |
||
122 | |||
123 | /** |
||
124 | * Retrieves the content of $name cache |
||
125 | * |
||
126 | * @param string $name cache name |
||
127 | * @param bool $compressed |
||
128 | * |
||
129 | * @return mixed |
||
130 | */ |
||
131 | public function get($name, $compressed = false) { |
||
155 | |||
156 | /** |
||
157 | * Locks file |
||
158 | * |
||
159 | * @param resource $handle |
||
160 | * @param bool $write |
||
161 | * |
||
162 | * @return bool |
||
163 | */ |
||
164 | protected function lockFile($handle, $write = false) { |
||
170 | |||
171 | /** |
||
172 | * Unlocks file |
||
173 | * |
||
174 | * @param resource $handle |
||
175 | * |
||
176 | * @return bool |
||
177 | */ |
||
178 | protected function unlockFile($handle) { |
||
184 | |||
185 | /** |
||
186 | * Retrieves information of Cache state |
||
187 | * |
||
188 | * @param bool $getFields |
||
189 | * |
||
190 | * @return array |
||
191 | */ |
||
192 | public function info($getFields = false) { |
||
216 | |||
217 | /** |
||
218 | * Gets all cache files |
||
219 | * |
||
220 | * @return array |
||
221 | */ |
||
222 | protected function getAllCacheFiles() { |
||
232 | |||
233 | } |
||
234 |