summaryrefslogtreecommitdiff
path: root/inc/cache.php
diff options
context:
space:
mode:
authorSimon McFarlane <simon@piston.pw>2015-05-26 23:31:47 -0700
committerSimon McFarlane <simon@piston.pw>2015-05-29 01:34:53 -0700
commit4b40f69a4e6d190f6d342875bd084c2a6c9d8b0f (patch)
treefcc5dc9efa24afcb0bda3740b59f0c4e81c42f62 /inc/cache.php
parent2ac451ecb7aaae1ed1402425b8df6a5cb9831f2b (diff)
parentd20149b57929c27da87a7d9603d85717da15c5bc (diff)
Merge remote-tracking branch 'upstream/master' into vichan-merge
Diffstat (limited to 'inc/cache.php')
-rw-r--r--inc/cache.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/inc/cache.php b/inc/cache.php
index d1200919..852aefa2 100644
--- a/inc/cache.php
+++ b/inc/cache.php
@@ -50,6 +50,17 @@ class Cache {
case 'php':
$data = isset(self::$cache[$key]) ? self::$cache[$key] : false;
break;
+ case 'fs':
+ $key = str_replace('/', '::', $key);
+ $key = str_replace("\0", '', $key);
+ if (!file_exists('tmp/cache/'.$key)) {
+ $data = false;
+ }
+ else {
+ $data = file_get_contents('tmp/cache/'.$key);
+ $data = json_decode($data, true);
+ }
+ break;
case 'redis':
if (!self::$cache)
self::init();
@@ -87,6 +98,11 @@ class Cache {
case 'xcache':
xcache_set($key, $value, $expires);
break;
+ case 'fs':
+ $key = str_replace('/', '::', $key);
+ $key = str_replace("\0", '', $key);
+ file_put_contents('tmp/cache/'.$key, json_encode($value));
+ break;
case 'php':
self::$cache[$key] = $value;
break;
@@ -113,6 +129,11 @@ class Cache {
case 'xcache':
xcache_unset($key);
break;
+ case 'fs':
+ $key = str_replace('/', '::', $key);
+ $key = str_replace("\0", '', $key);
+ @unlink('tmp/cache/'.$key);
+ break;
case 'php':
unset(self::$cache[$key]);
break;
@@ -134,6 +155,12 @@ class Cache {
case 'php':
self::$cache = array();
break;
+ case 'fs':
+ $files = glob('tmp/cache/*');
+ foreach ($files as $file) {
+ unlink($file);
+ }
+ break;
case 'redis':
if (!self::$cache)
self::init();