本文整理汇总了PHP中CacheManager::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP CacheManager::getInstance方法的具体用法?PHP CacheManager::getInstance怎么用?PHP CacheManager::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CacheManager
的用法示例。
在下文中一共展示了CacheManager::getInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_url_by_url
/**
* Get host by url
* @param string $url
* @param boolean $force get from database
* @return array
*/
public static function get_url_by_url($url, $force = false)
{
$host = self::get_or_create_host_by_url($url);
if (!$host || !isset($host['id']) || $host['id'] == 0) {
return false;
}
$host_id = intval($host['id']);
$cache_id = $host_id . '-' . implode('-', db::create_url_params_from_url($url));
if (!CacheManager::getInstance('urls')->get($cache_id) || $force) {
CacheManager::getInstance('urls')->set($cache_id, db::get_url_by_url($host_id, $url));
}
return CacheManager::getInstance('urls')->get($cache_id);
}
示例2: validateCache
/**
* Handle expired cache or update times_used counter
*/
private function validateCache()
{
$manager = CacheManager::getInstance();
$today = date(self::TIMESTAMP_FORMAT);
$entry = $manager->getSingleItem(array('uid'), array('uid' => $this->uid, 'expires' => array('operator' => '<', 'value' => $today)));
if (is_object($entry)) {
// object needs to be expired
unlink($this->cache_file);
$manager->deleteData(array('uid' => $this->uid));
} else {
// update times used
$manager->updateData(array('times_used' => '`times_used` + 1'), array('uid' => $this->uid));
}
}