Total Complexity | 9 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
9 | class JsonFileCacheProvider implements CacheProvider{ |
||
10 | private $cacheDir = null; |
||
11 | |||
12 | 57 | public function __construct($cacheDir = null){ |
|
13 | 57 | if(!$cacheDir) $this->cacheDir = __DIR__; |
|
14 | 3 | else $this->cacheDir = $cacheDir; |
|
15 | 57 | } |
|
16 | |||
17 | 4 | public function set($key,$jsonobj,$expireAt = null){ |
|
18 | 4 | $data = $jsonobj; |
|
19 | 4 | $data->expires_at = $expireAt; |
|
20 | 4 | $file = "{$this->cacheDir}/{$key}.json"; |
|
21 | 4 | if($fp = @fopen($file, "w")){ |
|
22 | 4 | fwrite($fp, json_encode($data)); |
|
23 | 4 | fclose($fp); |
|
24 | } |
||
25 | 4 | } |
|
26 | |||
27 | 4 | public function get($key){ |
|
38 | } |
||
39 | |||
40 | 4 | public function clear($key){ |
|
44 | } |
||
45 | } |
||
46 | } |