本文整理汇总了PHP中Util_Environment::cache_dir方法的典型用法代码示例。如果您正苦于以下问题:PHP Util_Environment::cache_dir方法的具体用法?PHP Util_Environment::cache_dir怎么用?PHP Util_Environment::cache_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Util_Environment
的用法示例。
在下文中一共展示了Util_Environment::cache_dir方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: log_filename
/**
* Return full path to log file for module
* Path used in priority
* 1) W3TC_DEBUG_DIR
* 2) WP_DEBUG_LOG
* 3) W3TC_CACHE_DIR
*
* @param unknown $module
* @param null $blog_id
* @return string
*/
public static function log_filename($module, $blog_id = null)
{
if (is_null($blog_id)) {
$blog_id = Util_Environment::blog_id();
}
$postfix = sprintf('%06d', $blog_id);
if (defined('W3TC_BLOG_LEVELS')) {
for ($n = 0; $n < W3TC_BLOG_LEVELS; $n++) {
$postfix = substr($postfix, strlen($postfix) - 1 - $n, 1) . '/' . $postfix;
}
}
$from_dir = W3TC_CACHE_DIR;
if (defined('W3TC_DEBUG_DIR') && W3TC_DEBUG_DIR) {
$dir_path = W3TC_DEBUG_DIR;
if (!is_dir(W3TC_DEBUG_DIR)) {
$from_dir = dirname(W3TC_DEBUG_DIR);
}
} else {
$dir_path = Util_Environment::cache_dir('log');
}
$filename = $dir_path . '/' . $postfix . '/' . $module . '.log';
if (!is_dir(dirname($filename))) {
Util_File::mkdir_from(dirname($filename), $from_dir);
}
return $filename;
}
示例2: __construct
/**
* Constructor
*
* @param array $config
*/
function __construct($config = array())
{
parent::__construct($config);
if (isset($config['cache_dir'])) {
$this->_cache_dir = trim($config['cache_dir']);
} else {
$this->_cache_dir = Util_Environment::cache_blog_dir($config['section'], $config['blog_id']);
}
$this->_exclude = isset($config['exclude']) ? (array) $config['exclude'] : array();
$this->_flush_timelimit = isset($config['flush_timelimit']) ? (int) $config['flush_timelimit'] : 180;
$this->_locking = isset($config['locking']) ? (bool) $config['locking'] : false;
if (isset($config['flush_dir'])) {
$this->_flush_dir = $config['flush_dir'];
} else {
if ($config['blog_id'] <= 0 && !isset($config['cache_dir'])) {
// clear whole section if we operate on master cache
// and in a mode when cache_dir not strictly specified
$this->_flush_dir = Util_Environment::cache_dir($config['section']);
} else {
$this->_flush_dir = $this->_cache_dir;
}
}
if (isset($config['use_wp_hash']) && $config['use_wp_hash']) {
$this->_use_wp_hash = true;
}
}
示例3: cache_blog_dir
/**
* Returns path to blog's cache dir
*
* @param string $section
* @param null|int $blog_id
* @return string
*/
public static function cache_blog_dir($section, $blog_id = null)
{
if (!Util_Environment::is_wpmu()) {
$postfix = '';
} else {
if (is_null($blog_id)) {
$blog_id = Util_Environment::blog_id();
}
$postfix = DIRECTORY_SEPARATOR . sprintf('%d', $blog_id);
if (defined('W3TC_BLOG_LEVELS')) {
for ($n = 0; $n < W3TC_BLOG_LEVELS; $n++) {
$postfix = DIRECTORY_SEPARATOR . substr($postfix, strlen($postfix) - 1 - $n, 1) . $postfix;
}
}
}
return Util_Environment::cache_dir($section) . $postfix;
}
示例4: get_usage_statistics_cache
/**
* Usage statistics uses one of other module's cache
* to store its temporary data
*/
public static function get_usage_statistics_cache()
{
static $cache = null;
if (is_null($cache)) {
$c = Dispatcher::config();
if ($c->get_boolean('objectcache.enabled')) {
$provider = Dispatcher::component('ObjectCache_WpObjectCache_Regular');
} else {
if ($c->get_boolean('dbcache.enabled')) {
$provider = Dispatcher::component('DbCache_Core');
} else {
if ($c->get_boolean('pgcache.enabled')) {
$provider = Dispatcher::component('PgCache_ContentGrabber');
} else {
if ($c->get_boolean('minify.enabled')) {
$provider = Dispatcher::component('Minify_Core');
} else {
return null;
}
}
}
}
$engineConfig = $provider->get_usage_statistics_cache_config();
$engineConfig['module'] = 'stats';
$engineConfig['blog_id'] = 0;
// count wpmu-wide stats
if ($engineConfig['engine'] == 'file') {
$engineConfig['cache_dir'] = Util_Environment::cache_dir('stats');
}
$cache = Cache::instance($engineConfig['engine'], $engineConfig);
}
return $cache;
}