include/helpers/cache.helper.php
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php if(!defined('DEDEINC')) exit("Request Error!");
/**
* 缓存小助手,支持文件和memcache
*
* @version $Id: cache.helper.php 1 10:46 2011-3-2 tianya $
* @package DedeCMS.Helpers
* @copyright Copyright (c) 2007 - 2010, DesDev, Inc.
* @license http://help.dedecms.com/usersguide/license.html
* @link http://www.dedecms.com
*/
/**
* 读缓存
*
* @access public
* @param string $prefix 前缀
* @param string $key 键
* @param string $is_memcache 是否为memcache缓存
* @return string
*/
if ( ! function_exists('GetCache'))
{
function GetCache($prefix, $key, $is_memcache = TRUE)
{
global $cache_helper_config;
$key = md5 ( $key );
/* 如果启用MC缓存 */
if ($is_memcache === TRUE && ! empty ( $cache_helper_config['memcache'] ) && $cache_helper_config['memcache'] ['is_mc_enable'] === 'Y')
{
$mc_path = empty ( $cache_helper_config['memcache'] ['mc'] [substr ( $key, 0, 1 )] ) ? $cache_helper_config['memcache'] ['mc'] ['default'] : $cache_helper_config['memcache'] ['mc'] [substr ( $key, 0, 1 )];
$mc_path = parse_url ( $mc_path );
$key = ltrim ( $mc_path ['path'], '/' ) . '_' . $prefix . '_' . $key;
if (empty ( $GLOBALS ['mc_' . $mc_path ['host']] ))
{
$GLOBALS ['mc_' . $mc_path ['host']] = new Memcache ( );
$GLOBALS ['mc_' . $mc_path ['host']]->connect ( $mc_path ['host'], $mc_path ['port'] );
}
return $GLOBALS ['mc_' . $mc_path ['host']]->get ( $key );
}
$key = substr ( $key, 0, 2 ) . '/' . substr ( $key, 2, 2 ) . '/' . substr ( $key, 4, 2 ) . '/' . $key;
$result = @file_get_contents ( DEDEDATA . "/cache/$prefix/$key.php" );
if ($result === false)
{
return false;
}
$result = str_replace("<?php exit('dedecms');?>\n\r", "", $result);
$result = @unserialize ( $result );
if($result ['timeout'] != 0 && $result ['timeout'] < time ())
{
return false;
}
return $result ['data'];
}
}
/**
* 写缓存
*
* @access public
后面还有 70 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。