forked from MythTV/mythweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cache.php
52 lines (41 loc) · 1.42 KB
/
Cache.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
class Cache {
private static $Instance = null;
public static $Engines = array('Cache_Null',
'Cache_APC',
'Cache_SHM',
'Cache_Memcache',
'Cache_Memcached'
);
public static function &get($key = null) {
$data = &Cache::$Instance->get($key);
if (!$data)
return null;
return $data;
}
public static function &getObject($key = null) {
$obj = &Cache::$Instance->get($key);
if (is_string($obj))
return unserialize($obj);
return $obj;
}
public static function set($key, $data, $lifeLength = 600) {
return Cache::$Instance->set($key, $data, $lifeLength);
}
public static function setObject($key, &$object, $lifeLength = 600) {
return Cache::$Instance->set($key, serialize($object), $lifeLength);
}
public static function initalize($engine) {
if (!in_array($engine, self::$Engines))
$engine = 'Cache_Null';
if (is_null(Cache::$Instance))
Cache::$Instance = new $engine();
}
public static function delete($key) {
return Cache::$Instance->delete($key);
}
public static function clear() {
return Cache::$Instance->clear();
}
}
Cache::initalize($_SESSION['cache_engine']);