本文整理匯總了PHP中CacheHandler::get方法的典型用法代碼示例。如果您正苦於以下問題:PHP CacheHandler::get方法的具體用法?PHP CacheHandler::get怎麽用?PHP CacheHandler::get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CacheHandler
的用法示例。
在下文中一共展示了CacheHandler::get方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: errorPic
$alliance = $corp->getAlliance();
// we dont generate pictures for non-members
if (array_search($alliance->getID(), config::get('cfg_allianceid')) === false && !array_search($corp->getID(), config::get('cfg_corpid')) === false && !array_search($pilot->getID(), config::get('cfg_pilotid')) === false) {
errorPic('Invalid pilot');
}
$id = abs(crc32($sig_name));
// check for cached version
if (file_exists(CacheHandler::exists("{$plt_ext_id}_sig_{$id}.jpg", 'img'))) {
// cache files for 120 minutes
if (time() - CacheHandler::age("{$plt_ext_id}_sig_{$id}.jpg", 'img') < 120 * 60 || lastKill($plt_id) > 120 * 60) {
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) || isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
header($_SERVER["SERVER_PROTOCOL"] . " 304 Not Modified");
die;
} else {
header('Content-Type: image/jpeg');
readfile(CacheHandler::get("{$plt_ext_id}_sig_{$id}.jpg", 'img'));
die;
}
}
}
$pid = $pilot->getExternalID();
$cachePath = $pilot->getPortraitPath(256);
$thumb = new thumb($pid, 256);
if (!$thumb->isCached()) {
$thumb->genCache();
}
// check template
if (!is_dir(dirname(__FILE__) . '/signatures/' . $sig_name)) {
errorPic('Template not found.');
}
// let the template do the work, we just output $im
示例2: killListToXML
/**
*
* @param KillList $killList
* @return string KillList as XML
*/
public static function killListToXML($killList)
{
global $idfeedversion;
$qry = DBFactory::getDBQuery();
$date = gmdate('Y-m-d H:i:s');
$xml = "<?xml version='1.0' encoding='UTF-8'?>\n\t\t<eveapi version='2' edkapi='" . $idfeedversion . "'>\n\t\t</eveapi>";
$sxe = new SimpleXMLElement($xml);
// Let's start making the xml.
$sxe->addChild('currentTime', $date);
$result = $sxe->addChild('result');
$kills = $result->addChild('rowset');
$kills->addAttribute('name', 'kills');
$kills->addAttribute('key', 'killID');
$kills->addAttribute('columns', 'killID,solarSystemID,killTime,moonID,hash,trust');
$count = 0;
$timing = '';
while ($kill = $killList->getKill()) {
if (config::get('km_cache_enabled') && CacheHandler::exists($kill->getID() . ".xml", 'mails')) {
$cachedRow = new SimpleXMLElement(CacheHandler::get($kill->getID() . ".xml", 'mails'));
IDFeed::addXMLElement($kills, $cachedRow);
continue;
}
$count++;
if ($kill->isClassified()) {
continue;
}
//$kill = Kill::getByID($kill->getID());
$row = $kills->addChild('row');
$row->addAttribute('killID', intval($kill->getExternalID()));
$row->addAttribute('killInternalID', intval($kill->getID()));
$row->addAttribute('solarSystemID', $kill->getSystem()->getExternalID());
$row->addAttribute('killTime', $kill->getTimeStamp());
$row->addAttribute('moonID', '0');
$row->addAttribute('hash', bin2hex(IDFeed::getHash($kill, true)));
$row->addAttribute('trust', 3);
$victim = Pilot::getByID($kill->getVictimID());
$victimCorp = Corporation::getByID($kill->getVictimCorpID());
$victimAlliance = Alliance::getByID($kill->getVictimAllianceID());
$victimrow = $row->addChild('victim');
if ($victim->getName() == $kill->getVictimShipName()) {
$victimrow->addAttribute('characterID', "0");
$victimrow->addAttribute('characterName', "");
} else {
$victimrow->addAttribute('characterID', $victim->getExternalID());
$victimrow->addAttribute('characterName', $victim->getName());
}
$victimrow->addAttribute('corporationID', $victimCorp->getExternalID());
$victimrow->addAttribute('corporationName', $victimCorp->getName());
if ($victimAlliance->isFaction()) {
$victimrow->addAttribute('allianceID', 0);
$victimrow->addAttribute('allianceName', '');
$victimrow->addAttribute('factionID', $victimAlliance->getFactionID());
$victimrow->addAttribute('factionName', $victimAlliance->getName());
} else {
$victimrow->addAttribute('allianceID', $victimAlliance->getExternalID());
$victimrow->addAttribute('allianceName', $victimAlliance->getName());
$victimrow->addAttribute('factionID', 0);
$victimrow->addAttribute('factionName', '');
}
$victimrow->addAttribute('damageTaken', $kill->getDamageTaken());
$victimrow->addAttribute('shipTypeID', $kill->getVictimShipExternalID());
$involved = $row->addChild('rowset');
$involved->addAttribute('name', 'attackers');
$involved->addAttribute('columns', 'characterID,characterName,corporationID,corporationName,allianceID,allianceName,factionID,factionName,securityStatus,damageDone,finalBlow,weaponTypeID,shipTypeID');
$sql = "SELECT ind_sec_status, ind_all_id, ind_crp_id,\n\t\t\t\tind_shp_id, ind_wep_id, ind_order, ind_dmgdone, plt_id, plt_name,\n\t\t\t\tplt_externalid, crp_name, crp_external_id,\n\t\t\t\twtype.typeName AS wep_name FROM kb3_inv_detail\n\t\t\t\tJOIN kb3_pilots ON (plt_id = ind_plt_id)\n\t\t\t\tJOIN kb3_corps ON (crp_id = ind_crp_id)\n\t\t\t\tJOIN kb3_invtypes wtype ON (ind_wep_id = wtype.typeID)\n\t\t\t\tWHERE ind_kll_id = " . $kill->getID() . " ORDER BY ind_order ASC";
$qry->execute($sql);
while ($inv = $qry->getRow()) {
$invrow = $involved->addChild('row');
if (strpos($inv['plt_name'], '- ') !== false) {
$inv['plt_name'] = substr($inv['plt_name'], strpos($inv['plt_name'], '- ') + 2);
} else {
if (strpos($inv['plt_name'], '#') !== false) {
$name = explode("#", $inv['plt_name']);
$inv['plt_name'] = $name[3];
}
}
if ($inv['plt_name'] == $inv['wep_name']) {
$invrow->addAttribute('characterID', 0);
$invrow->addAttribute('characterName', "");
$invrow->addAttribute('weaponTypeID', 0);
$invrow->addAttribute('shipTypeID', $inv['ind_wep_id']);
} else {
$invrow->addAttribute('characterID', $inv['plt_externalid']);
$invrow->addAttribute('characterName', $inv['plt_name']);
$invrow->addAttribute('weaponTypeID', $inv['ind_wep_id']);
$invrow->addAttribute('shipTypeID', $inv['ind_shp_id']);
}
$invrow->addAttribute('corporationID', $inv['crp_external_id']);
$invrow->addAttribute('corporationName', $inv['crp_name']);
$invAlliance = Alliance::getByID($inv['ind_all_id']);
if ($invAlliance->isFaction()) {
$invrow->addAttribute('allianceID', 0);
$invrow->addAttribute('allianceName', '');
$invrow->addAttribute('factionID', $invAlliance->getFactionID());
$invrow->addAttribute('factionName', $invAlliance->getName());
//.........這裏部分代碼省略.........