本文整理汇总了PHP中CacheManager::isCached方法的典型用法代码示例。如果您正苦于以下问题:PHP CacheManager::isCached方法的具体用法?PHP CacheManager::isCached怎么用?PHP CacheManager::isCached使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CacheManager
的用法示例。
在下文中一共展示了CacheManager::isCached方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createReaction
private function createReaction($id)
{
$key = "ReactionObject-{$id}";
if ($this->cacheMgr->isCached($key)) {
return $this->cacheMgr->load($key);
} else {
$object = new Reaction($id);
$this->cacheMgr->save($key, $object, 3600);
return $object;
}
}
示例2: getAllSystems
/**
* Returns all columns of all rows from the systems table as an associative array keyed by systemID.
* @param none
* @return array
*/
public function getAllSystems()
{
$key = __METHOD__ . "(" . implode(",", func_get_args()) . ")";
if ($this->cacheMgr->isCached($key)) {
$systems = $this->cacheMgr->load($key);
} else {
$sql = "SELECT systemID, systemName FROM {$this->dbPrefix}systems ORDER BY systemID ASC;";
$query = $this->pdo->prepare($sql);
$query->execute();
if ($systems = $query->fetchAll(PDO::FETCH_KEY_PAIR)) {
if (count($systems) > 0) {
$this->cacheMgr->save($key, $systems, 86400);
}
}
$query->closeCursor();
$query = null;
}
return $systems;
}