forked from GithubBackups/vichan
implement non-expiring store() function
this will allow longer term storage of data
This commit is contained in:
parent
b9e443a1e2
commit
303ed52812
35
inc/cache.php
Normal file → Executable file
35
inc/cache.php
Normal file → Executable file
@ -111,6 +111,41 @@ class Cache {
|
||||
if ($config['debug'])
|
||||
$debug['cached'][] = $key . ' (set)';
|
||||
}
|
||||
public static function store($key, $value) {
|
||||
global $config, $debug;
|
||||
|
||||
$key = $config['cache']['prefix'] . $key;
|
||||
|
||||
switch ($config['cache']['enabled']) {
|
||||
case 'memcached':
|
||||
if (!self::$cache)
|
||||
self::init();
|
||||
self::$cache->set($key, $value);
|
||||
break;
|
||||
case 'redis':
|
||||
if (!self::$cache)
|
||||
self::init();
|
||||
self::$cache->set($key, json_encode($value));
|
||||
break;
|
||||
case 'apc':
|
||||
apc_store($key, $value);
|
||||
break;
|
||||
case 'xcache':
|
||||
xcache_set($key, $value);
|
||||
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;
|
||||
}
|
||||
|
||||
if ($config['debug'])
|
||||
$debug['cached'][] = $key . ' (set)';
|
||||
}
|
||||
public static function delete($key) {
|
||||
global $config, $debug;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user