Page.class.php
938 Bytes
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
<?php
/**
* 页面级缓存(存储内容小于1MB)
*
* @name QLib_Utils_Cache_Page
* @package Lib/Utils/Cache
* @author whb whb@yoho.cn
* @since 1.0
*/
class Lib_Utils_Cache_Page
{
private static $cache;
private static $options = array ('domain' => 'wwww', 'class' => 'page' );
private static $key = 'yh_cache_page_';
//存储四个小时
const EXPIRE = 14400;
private static function cache()
{
if (! isset ( self::$cache ))
{
self::$cache = Util_Cache::factory ( self::$options);
}
return self::$cache;
}
private static function encryptKey($key)
{
return md5(self::$key.md5($key));
}
public static function set($key, $data)
{
return self::cache()->set(self::encryptKey($key), $data, self::EXPIRE);
}
public static function get($key)
{
return self::cache()->get(self::encryptKey($key));
}
}