Page.class.php 938 Bytes
<?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));
    }
}