1 | <?php |
||
18 | abstract class BaseManager |
||
19 | { |
||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | protected static $cFileName; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | protected static $cacheDirectory; |
||
29 | |||
30 | /** |
||
31 | * @param string $cacheDirectory |
||
32 | */ |
||
33 | public static function setCacheDirectory($cacheDirectory) { |
||
36 | |||
37 | /** |
||
38 | * @param $cFileName |
||
39 | */ |
||
40 | public static function setCFileName($cFileName) |
||
44 | |||
45 | /** |
||
46 | * @return string |
||
47 | */ |
||
48 | public static function getCFileName() |
||
52 | |||
53 | /** |
||
54 | * @return string |
||
55 | * |
||
56 | * Return absolute file path which store cache list |
||
57 | */ |
||
58 | public static function getCFilePath() |
||
63 | |||
64 | /** |
||
65 | * Unique string for each server |
||
66 | * @param string $salt |
||
67 | * @return string |
||
68 | */ |
||
69 | public static function getUniqueString($salt = '') |
||
74 | |||
75 | /** |
||
76 | * @param $key |
||
77 | * @return bool|string |
||
78 | * |
||
79 | * Return absolute file path of caching object |
||
80 | */ |
||
81 | public static function get($key) |
||
95 | |||
96 | /** |
||
97 | * @param $key |
||
98 | * @param $filePath |
||
99 | * @return bool |
||
100 | * |
||
101 | * Save $key and $filePath in cacheList |
||
102 | */ |
||
103 | public static function set($key, $filePath, $ttl) |
||
114 | |||
115 | /** |
||
116 | * @param $key |
||
117 | * @return bool |
||
118 | * |
||
119 | * Remove caching object file and remove from cache list |
||
120 | */ |
||
121 | public static function remove($key) |
||
128 | |||
129 | /** |
||
130 | * @param $key |
||
131 | * @return bool |
||
132 | */ |
||
133 | public static function has($key) |
||
142 | |||
143 | /** |
||
144 | * @return array |
||
145 | * |
||
146 | * Return cache list in array |
||
147 | */ |
||
148 | protected static function getCacheList() |
||
156 | |||
157 | /** |
||
158 | * @param $cacheList |
||
159 | * @return bool |
||
160 | */ |
||
161 | protected static function setCacheList($cacheList) |
||
165 | |||
166 | /** |
||
167 | * @param $array |
||
168 | * @return string |
||
169 | */ |
||
170 | protected static function encode($array) |
||
174 | |||
175 | /** |
||
176 | * @param $string |
||
177 | * @return array |
||
178 | */ |
||
179 | protected static function decode($string) |
||
183 | } |
||
184 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: