cache_sql.php
1.03 KB
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
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_sql.php 24721 2011-10-09 10:30:22Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class ultrax_cache {
function ultrax_cache($conf) {
$this->conf = $conf;
}
function get_cache($key) {
static $data = null;
if(!isset($data[$key])) {
$cache = C::t('common_cache')->fetch($key);
if(!$cache) {
return false;
}
$data[$key] = unserialize($cache['cachevalue']);
if($cache['life'] && ($cache['dateline'] < time() - $data[$key]['life'])) {
return false;
}
}
return $data[$key]['data'];
}
function set_cache($key, $value, $life) {
$data = array(
'cachekey' => $key,
'cachevalue' => serialize(array('data' => $value, 'life' => $life)),
'dateline' => time(),
);
return C::t('common_cache')->insert($data);
}
function del_cache($key) {
return C::t('common_cache')->delete($key);
}
}