Conditions | 3 |
Paths | 3 |
Total Lines | 12 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
32 | public static function fromCachedFile(string $file) { |
||
33 | if (!file_exists($file)) { |
||
34 | return null; |
||
35 | } |
||
36 | |||
37 | $memcache = new \MySociety\TheyWorkForYou\Memcache(); |
||
38 | $content = $memcache->get($file); |
||
39 | if (!$content) { |
||
|
|||
40 | $content = file_get_contents($file); |
||
41 | $memcache->set($file, $content, 60 * 60 * 1); // Cache for 1 hour |
||
42 | } |
||
43 | return static::fromJson($content); |
||
44 | } |
||
58 |