本文整理汇总了PHP中Cache::Get方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::Get方法的具体用法?PHP Cache::Get怎么用?PHP Cache::Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cache
的用法示例。
在下文中一共展示了Cache::Get方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetQueryResult
static public function GetQueryResult( $sql, $one=true, $cache=0 )
{
$mkey = Cache::GetStringKey($sql);
if ( $cache > 0 ) {
$ret = Cache::Get($mkey);
if ( $ret ) return $ret;
}
$ret = array();
if ( $result = self::Query($sql) )
{
while ( $row = mysql_fetch_assoc($result) )
{
$row = array_change_key_case($row, CASE_LOWER);
if ( $one )
{
$ret = $row;
break;
}else{
array_push( $ret, $row );
}
}
@mysql_free_result( $result );
}
if ($ret) Cache::Set($mkey, $ret, 0, $cache);
return $ret;
}
示例2: GetAllBundles
function GetAllBundles()
{
$oCache = new Cache($this->sUsername . 'tags/bundles/all', $this->iCacheTime);
if (!$oCache->Check()) {
if ($aResult = $this->DeliciousRequest('tags/bundles/all')) {
$aBundles = array();
foreach ($aResult['items'] as $aCurBundle) {
$aBundles[] = array('name' => $aCurBundle['attributes']['NAME'], 'tags' => $aCurBundle['attributes']['TAGS']);
}
$oCache->Set($aBundles);
} else {
$oCache->Set(false);
}
}
return $oCache->Get();
}
示例3: getActiveDownloads
/**
* Returns the cached list of active downloads
*/
public static function getActiveDownloads()
{
$cacheKey = self::_getCacheKey();
$urls = Cache::Get($cacheKey);
return $urls ?: [];
}
示例4: fetchBuild
private function fetchBuild($slug, $build)
{
$response = array();
if (Cache::has('modpack.' . $slug) && empty($this->client) && empty($this->key)) {
$modpack = Cache::Get('modpack.' . $slug);
} else {
$modpack = Modpack::where("slug", "=", $slug)->first();
if (empty($this->client) && empty($this->key)) {
Cache::put('modpack.' . $slug, $modpack, 5);
}
}
if (empty($modpack)) {
return array("error" => "Modpack does not exist");
}
$buildpass = $build;
if (Cache::has('modpack.' . $slug . '.build.' . $build) && empty($this->client) && empty($this->key)) {
$build = Cache::get('modpack.' . $slug . '.build.' . $build);
} else {
$build = Build::with('Modversions')->where("modpack_id", "=", $modpack->id)->where("version", "=", $build)->first();
if (empty($this->client) && empty($this->key)) {
Cache::put('modpack.' . $slug . '.build.' . $buildpass, $build, 5);
}
}
if (empty($build)) {
return array("error" => "Build does not exist");
}
$response['minecraft'] = $build->minecraft;
$response['minecraft_md5'] = $build->minecraft_md5;
$response['java'] = $build->min_java;
$response['memory'] = $build->min_memory;
$response['forge'] = $build->forge;
$response['mods'] = array();
if (!Input::has('include')) {
if (Cache::has('modpack.' . $slug . '.build.' . $buildpass . 'modversion') && empty($this->client) && empty($this->key)) {
$response['mods'] = Cache::get('modpack.' . $slug . '.build.' . $buildpass . 'modversion');
} else {
foreach ($build->modversions as $modversion) {
$response['mods'][] = array("name" => $modversion->mod->name, "version" => $modversion->version, "md5" => $modversion->md5, "url" => Config::get('solder.mirror_url') . 'mods/' . $modversion->mod->name . '/' . $modversion->mod->name . '-' . $modversion->version . '.zip');
}
usort($response['mods'], function ($a, $b) {
return strcasecmp($a['name'], $b['name']);
});
Cache::put('modpack.' . $slug . '.build.' . $buildpass . 'modversion', $response['mods'], 5);
}
} else {
if (Input::get('include') == "mods") {
if (Cache::has('modpack.' . $slug . '.build.' . $buildpass . 'modversion.include.mods') && empty($this->client) && empty($this->key)) {
$response['mods'] = Cache::get('modpack.' . $slug . '.build.' . $buildpass . 'modversion.include.mods');
} else {
foreach ($build->modversions as $modversion) {
$response['mods'][] = array("name" => $modversion->mod->name, "version" => $modversion->version, "md5" => $modversion->md5, "pretty_name" => $modversion->mod->pretty_name, "author" => $modversion->mod->author, "description" => $modversion->mod->description, "link" => $modversion->mod->link, "donate" => $modversion->mod->donatelink, "url" => Config::get('solder.mirror_url') . 'mods/' . $modversion->mod->name . '/' . $modversion->mod->name . '-' . $modversion->version . '.zip');
}
usort($response['mods'], function ($a, $b) {
return strcasecmp($a['name'], $b['name']);
});
Cache::put('modpack.' . $slug . '.build.' . $buildpass . 'modversion.include.mods', $response['mods'], 5);
}
} else {
$request = explode(",", Input::get('include'));
if (Cache::has('modpack.' . $slug . '.build.' . $buildpass . 'modversion.include.' . $request) && empty($this->client) && empty($this->key)) {
$response['mods'] = Cache::get('modpack.' . $slug . '.build.' . $buildpass . 'modversion.include.' . $request);
} else {
foreach ($build->modversions as $modversion) {
$data = array("name" => $modversion->mod->name, "version" => $modversion->version, "md5" => $modversion->md5);
$mod = (array) $modversion->mod;
$mod = $mod['attributes'];
foreach ($request as $type) {
if (isset($mod[$type])) {
$data[$type] = $mod[$type];
}
}
$response['mods'][] = $data;
}
usort($response['mods'], function ($a, $b) {
return strcasecmp($a['name'], $b['name']);
});
Cache::put('modpack.' . $slug . '.build.' . $buildpass . 'modversion.include.' . $request, $response['mods'], 5);
}
}
}
return $response;
}
示例5: get_player_certs
//.........这里部分代码省略.........
$temp .= '<tr><td>' . htmlentities($key) . ': </td><td>' . htmlentities($value) . '</td></tr>';
}
}
$temp .= '</table>';
$item_stats_lookup[(string) $stat->marketlisting_id] = $temp;
}
break;
default:
break;
}
}
//Cache
$cached_market_listings = array();
$cached_market_listings['data'] = $market_listings;
$cached_market_listings['stats'] = $item_stats_lookup;
Cache::put($cache_key_player_market, $cached_market_listings, 30);
}
}
}
if ($web_prefs['show_craftables']) {
if (isset($web_prefs['show_progress'])) {
if ($web_prefs['show_progress']) {
$progress = Progress::where('db_id', '=', $player->db_id)->order_by('updated_at', 'DESC')->first();
} else {
$progress = null;
}
} else {
$progress = Progress::where('db_id', '=', $player->db_id)->order_by('updated_at', 'DESC')->first();
}
if (!empty($progress)) {
$cache_key_progress = $player->db_id . "_progress";
$progress = $progress->entry;
$progress_md5 = md5($progress);
if (Cache::Get($cache_key_progress . "_md5_cc") != $progress_md5) {
$progress = unserialize($progress);
if (isset($progress->unlocks)) {
$master_cert_list = array();
//all odd number certs from 799 to 1245
//category names from 766 to 783
//arsenal = 1398
/*
766 = base assault
767 = base biotech
768 = base dreadnaught
769 = base engineer
770 = base recon
774 = firecat
775 = tigerclaw
776 = dragonfly
777 = recluse
778 = rhino
779 = mammoth
1398 = arsenal
780 = electron
781 = bastion
782 = nighthawk
783 = raptor
*/
//certs we don't care about
$useless_certs = array(784, 785, 786, 788, 789, 790, 791, 792, 794, 1154, 1359, 1366, 1367, 1371, 1372, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392);
$unlocked_base_assault = 0;
$unlocked_base_biotech = 0;
$unlocked_base_dreadnaught = 0;
$unlocked_base_engineer = 0;
$unlocked_base_recon = 0;
示例6: Get_Player_Craftables
public function Get_Player_Craftables($db_id)
{
$web_prefs = PlayerAPIController::Get_Player_Webprefs($db_id);
if ($web_prefs['show_craftables'] != 1) {
return Response::json(array('status' => 'error', 'error' => 'Player is not allowing craftables viewing.'));
} else {
$unlocks = PlayerAPIController::Get_Player_Unlocks($db_id);
$md5_unlocks = md5($unlocks);
$unlocks = json_decode($unlocks, true);
if ($unlocks['status'] != "error") {
if (Cache::Get($this->class_name . "_" . $db_id . "_Craftables_MD5") != $md5_unlocks) {
$master_cert_list = array();
//all odd number certs from 799 to 1245
//category names from 766 to 783
/*
766 = base assault
767 = base biotech
768 = base dreadnaught
769 = base engineer
770 = base recon
774 = firecat
775 = tigerclaw
776 = dragonfly
777 = recluse
778 = rhino
779 = mammoth
780 = electron
781 = bastion
782 = nighthawk
783 = raptor
*/
//certs we don't care about
$useless_certs = array(784, 785, 786, 788, 789, 790, 791, 792, 794, 1154, 1359, 1366, 1367, 1371, 1372, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392);
$unlocked_base_assault = 0;
$unlocked_base_biotech = 0;
$unlocked_base_dreadnaught = 0;
$unlocked_base_engineer = 0;
$unlocked_base_recon = 0;
$unlocked_firecat = 0;
$unlocked_tigerclaw = 0;
$unlocked_dragonfly = 0;
$unlocked_recluse = 0;
$unlocked_rhino = 0;
$unlocked_mammoth = 0;
$unlocked_electron = 0;
$unlocked_bastion = 0;
$unlocked_nighthawk = 0;
$unlocked_raptor = 0;
foreach ($unlocks as $progress_certs) {
//Make a master list of certs, note that certs are in numerical sorted order so we are able to do a fast merge
for ($i = 0; $i < count($progress_certs); $i++) {
if (!in_array($progress_certs[$i], $master_cert_list)) {
if (!in_array($progress_certs[$i], $useless_certs)) {
//unlock flags
if ($progress_certs[$i] == 766) {
$unlocked_base_assault = 1;
}
if ($progress_certs[$i] == 767) {
$unlocked_base_biotech = 1;
}
if ($progress_certs[$i] == 768) {
$unlocked_base_dreadnaught = 1;
}
if ($progress_certs[$i] == 769) {
$unlocked_base_engineer = 1;
}
if ($progress_certs[$i] == 770) {
$unlocked_base_recon = 1;
}
if ($progress_certs[$i] == 774) {
$unlocked_firecat = 1;
}
if ($progress_certs[$i] == 775) {
$unlocked_tigerclaw = 1;
}
if ($progress_certs[$i] == 776) {
$unlocked_dragonfly = 1;
}
if ($progress_certs[$i] == 777) {
$unlocked_recluse = 1;
}
if ($progress_certs[$i] == 778) {
$unlocked_rhino = 1;
}
if ($progress_certs[$i] == 779) {
$unlocked_mammoth = 1;
}
if ($progress_certs[$i] == 780) {
$unlocked_electron = 1;
}
if ($progress_certs[$i] == 781) {
$unlocked_bastion = 1;
}
if ($progress_certs[$i] == 782) {
$unlocked_nighthawk = 1;
}
if ($progress_certs[$i] == 783) {
$unlocked_raptor = 1;
}
//.........这里部分代码省略.........
示例7: get_market_item_graph
public function get_market_item_graph($sdb_id, $rarity)
{
if ($sdb_id == null || $rarity == null) {
return Response::error('404');
}
//check the cache, if the date on the cache is different than todays date than remake the graph else return the cache
$cache_key_graphs = "Market_Graph";
$cached_graph = Cache::Get($cache_key_graphs . "_" . $sdb_id . "_" . $rarity);
if (empty($cached_graph)) {
$cached_graph['last_generated'] = 0;
}
if ($cached_graph['last_generated'] != gmdate("Y-m-d")) {
//Fire up those databases
//We need to query all the previously listed sdb_id's with the same quality so lets do that.
$item_listings = MarketListing::where(function ($query) use($sdb_id, $rarity) {
$query->where('item_sdb_id', '=', $sdb_id);
$query->where('rarity', '=', $rarity);
$query->where('active', '=', 0);
$query->where('created_at', '<', gmdate("Y-m-d"));
$query->order_by('created_at', 'ASC');
})->get(array('created_at', 'title', 'rarity', 'price_cy', 'price_per_unit', 'quantity'));
if ($item_listings) {
//Look at all these variables!
$max_listing = 0.0;
$min_listing = 100000000.0;
$all_time_max_listing = 0.0;
$all_time_min_listing = 100000000.0;
$max_listing_date = "";
$min_listing_date = "";
$item_name = $item_listings[0]->title;
//remove the ^Q or ^###
$temp_name = explode("^", $item_name);
$is_resource = 0;
if (isset($temp_name[1])) {
if ($temp_name[1] != "Q") {
//this is a resource item, we need to use unit price, not price_cy
$is_resource = 1;
}
}
$item_name = $temp_name[0];
$market_info_javascript_range = "[";
$market_info_javascript_average = "[";
$item_running_average = array();
$last_date = explode(" ", $item_listings[0]->created_at)[0];
$last_date_supply = 0;
$counter = 0;
$index = 0;
$i = 0;
$total_listings = count($item_listings);
//find an average, max and min price per day
foreach ($item_listings as $market_listing) {
//babies first market check
if ($is_resource && $market_listing->quantity > 100 || !$is_resource) {
//override for price_cy or price_per_unit
if ($is_resource) {
$price_field = $market_listing->price_per_unit;
} else {
$price_field = $market_listing->price_cy;
}
$date = explode(" ", $market_listing->created_at)[0];
if ($last_date != $date) {
$last_date = $date;
if ($counter != 0) {
//there is an issue with the first item also being the only item for that day, avoid that (bad programming general)
if ($i != 1) {
//the average has to be calculated because we have more than one data point for this day
if ($is_resource) {
$calc_average = number_format($item_running_average[$index]['average'] / $counter, 3);
} else {
$calc_average = floor($item_running_average[$index]['average'] / ($counter + 1));
}
//check to make sure the average isnt below the min, this happens when we have only two data points and they are significantly different
if ($calc_average < $item_running_average[$index]['low']) {
//re-do the average, this should NEVER happen for resources!
$calc_average = floor($item_running_average[$index]['average'] / $counter);
}
$item_running_average[$index]['average'] = $calc_average;
}
} else {
//we only have one data point thus it is the average
$item_running_average[$index]['average'] = $price_field;
$max_listing = $price_field;
$min_listing = $price_field;
}
$item_running_average[$index]['high'] = $max_listing;
$item_running_average[$index]['low'] = $min_listing;
$min_listing = 100000000.0;
$max_listing = 0.0;
$counter = 0;
$index = $index + 1;
if ($is_resource) {
//reset the supply counter
$last_date_supply = 0;
}
}
if (!empty($item_running_average[$index]['average'])) {
$item_running_average[$index]['average'] = $item_running_average[$index]['average'] + $price_field;
$item_running_average[$index]['date'] = $date;
} else {
$item_running_average[$index]['average'] = $price_field;
//.........这里部分代码省略.........
示例8: get_single_battleframe
public function get_single_battleframe($name = NULL, $frame_name = NULL)
{
//searching by name, null name = no buenos
if ($name == NULL || $frame_name == NULL) {
return Response::error('404');
} else {
$input_name = urldecode($name);
}
$valid_frame_name = array('assault', 'firecat', 'tigerclaw', 'biotech', 'recluse', 'dragonfly', 'dreadnaught', 'rhino', 'mammoth', 'engineer', 'electron', 'bastion', 'recon', 'raptor', 'nighthawk', 'arsenal');
if (!in_array($frame_name, $valid_frame_name)) {
return Response::error('404');
}
//Look up the player, latest to account for deletes with the same name
$player = Player::where('name', '=', $input_name)->order_by('created_at', 'DESC')->first();
//no player found, why not search?
if (!$player) {
return Response::error('404');
}
//escape for output in title
$playerName = htmlentities($player->name);
//Player website preferences
$web_prefs = WebsitePref::where('db_id', '=', $player->db_id)->first();
if (isset($web_prefs->attributes)) {
$web_prefs = $web_prefs->attributes;
}
//loadouts
/*
Mappings:
$loadout->Gear[$i] = Currently equipped items array
$loadout->Gear[$i]->slot_index
$loadout->Gear[$i]->info->durability->pool
$loadout->Gear[$i]->info->durability->current
$loadout->Gear[$i]->info->attribute_modifiers[$k] = array of custom attributes for this item
$loadout->Gear[$i]->info->quality = The quality of the crafted item
$loadout->Gear[$i]->info->creator_guid = the creators unique player ID
$loadout->Gear[$i]->info->item_sdb_id = The root item this was crafted from
$loadout->Weapons[$i] = Currently equiped weapons array
$loadout->Weapons[$i]->info->durability->pool
$loadout->Weapons[$i]->info->durability->current
$loadout->Weapons[$i]->info->attribute_modifiers[$k]
$loadout->Weapons[$i]->info->quality
$loadout->Weapons[$i]->info->creator_guid
$loadout->Weapons[$i]->info->item_sdb_id
$loadout->Weapons[$i]->allocated_power
$loadout->Weapons[$i]->slot_index = Weapon slot, 0 is main hand, 1 is alt weapon
*/
/*
Attribute modifiers mapping:
5 = Jet Energy Recharge
6 = health
7 = health regen
12 = Run Speed
29 = weapon splash radius
35 = Energy (for jetting)
37 = Jump Height
950 = Max durability pool
951 = Mass (unmodified - YOU MUST take the abs of this to get it to display correctly!)
952 = Power (unmodified - YOU MUST take the abs of this to get it to display correctly!)
953 = CPU (unmodified - YOU MUST take the abs of this to get it to display correctly!)
956 = clip size
954 = damage per round
977 = Damage
978 = Debuff Duration
1121= Air Sprint
Defaults for weapons are set in the "hstats" table.
*/
if (isset($web_prefs['show_loadout'])) {
if ($web_prefs['show_loadout'] == 1) {
$loadout = Loadout::where('db_id', '=', $player->db_id)->first();
} else {
$loadout = null;
}
} else {
$loadout = Loadout::where('db_id', '=', $player->db_id)->first();
}
if ($loadout) {
//Lets play the cache game, where all the stuff is stored locally and the points don't matter!
$loadout = unserialize($loadout->entry);
//VERSION 0.6 CHECKING (Array = Good, Object = BAD!)
if (gettype($loadout) == "object") {
//This is from version 0.6, we can no longer use this data.
$loadout = null;
}
$cache_key_loadouts = $player->db_id . "_loadouts";
$loadout_md5 = md5(serialize($loadout));
if (Cache::Get($cache_key_loadouts . '_md5') != $loadout_md5 && $loadout != null) {
//Oh I am playing the game, the one that will take me to my end.
//Make sure this isnt a terrible send
if (isset($loadout[0]->Gear)) {
for ($k = 0; $k < count($loadout); $k++) {
if ($loadout[$k]->Chassis_ID == 77733 || $loadout[$k]->Chassis_ID == 82394 || $loadout[$k]->Chassis_ID == 31334) {
//ignore the training frame
} else {
//Break each loadout into its own cache
Cache::forever($cache_key_loadouts . '_' . $loadout[$k]->Chassis_ID, $loadout[$k]);
}
}
//Cache the loadout md5 so we can call it again later
//.........这里部分代码省略.........
示例9: GetFans
public function GetFans($sUsername)
{
if (function_exists('json_decode')) {
$oCache = new Cache("fans/{$sUsername}", $this->iCacheTime);
if (!$oCache->Check()) {
if ($sJson = $this->HttpRequest(PHP_DELICIOUS_JSON_URL . "fans/{$sUsername}")) {
$oCache->Set(json_decode($sJson));
} else {
$oCache->Set(false);
}
}
return $oCache->Get();
}
return false;
}
示例10: CacheGet
/**
* Get content from cache
*
* @param string $request
* @param object $params
* @return bool
*/
private function CacheGet($request, $IgnoreRewrite = false)
{
if ($this->RewriteCache && !$IgnoreRewrite)
return false;
return $this->Cache->Get($request);
}
示例11: md5
<?php
/**
* Typeframe Install application
*
* admin-side browse controller
*/
// define URL, cache key
$url = TYPEF_PROVIDER . '/xml?license=' . TYPEF_LICENSE_KEY;
$cachekey = 'install-browse-packages-' . md5($url);
// load packages if cached
if (Cache::Get($cachekey)) {
foreach (Cache::Get($cachekey) as $row) {
$pm->addLoop('packages', $row);
}
} else {
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, $url);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
$cachecontents = array();
if ($buffer) {
$xml = simplexml_load_string($buffer);
if ($xml) {
$pm->setVariable('page', (string) $xml['page']);
$pm->setVariable('totalpages', (string) $xml['totalpages']);
$pm->setVariable('totalpackages', (string) $xml['totalpackages']);
foreach ($xml->package as $p) {
$cachecontents[] = $row = array('packagename' => (string) $p->name, 'packagetitle' => (string) $p->title, 'packageurl' => (string) $p->url, 'packagedescr' => (string) $p->description, 'lastrevision' => (string) $p->lastrevision, 'lastversion' => (string) $p->lastversion, 'lastdate' => (string) $p->lastdate);