本文整理匯總了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));
}
}