summaryrefslogtreecommitdiff
path: root/inc/cache.php
diff options
context:
space:
mode:
authorczaks <marcin@6irc.net>2016-02-09 12:37:03 +0100
committerczaks <marcin@6irc.net>2016-02-09 12:37:03 +0100
commitc53f13bf90716461780fef0a2b4b6e2b5b3cb002 (patch)
tree5cd18f303da0b0e6fdc87f175adf5f5f86d881e2 /inc/cache.php
parentfe66c51a19920378885fb790d341cc50c933b046 (diff)
parent028fd3df15b2e2edc96c5b84156b0b039ea16562 (diff)
Merge branch 'master' of https://github.com/vichan-devel/vichan
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();