本文整理汇总了PHP中Illuminate\Support\Facades\Cache::has方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::has方法的具体用法?PHP Cache::has怎么用?PHP Cache::has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Cache
的用法示例。
在下文中一共展示了Cache::has方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hasAccessObject
public function hasAccessObject()
{
if (Cache::has('citrix_access_object')) {
return true;
}
return false;
}
示例2: handle
/**
* @inheritdoc
*/
public function handle($arguments)
{
if (!Cache::has('site-' . $arguments)) {
$this->replyWithMessage("Não foi encontrado nenhum site com esse argumento.");
return;
}
$site = Cache::get('site-' . $arguments);
// Validate if the URL isn't on the database yet
if (Site::where('url', '=', $site)->first() != null) {
$this->replyWithMessage("O site {$site} já se encontra na base de dados.");
return;
}
$site_obj = new Site();
$site_obj->url = $site;
$site_obj->save();
$this->replyWithMessage($site . " foi adicionado à base de dados.", true);
// Notify the sitesbloqueados.pt about the new site
$url = 'https://sitesbloqueados.pt/wp-json/ahoy/refresh';
$cmd = "curl -X GET -H 'Content-Type: application/json'";
$cmd .= " " . "'" . $url . "'";
$cmd .= " > /dev/null 2>&1 &";
exec($cmd, $output);
// Flush the PAC cache
Cache::tags(['generate_pac'])->flush();
// Remove the cache
Cache::forget('site-' . $arguments);
Cache::forget('site-list');
}
示例3: prettifyOnlineStatus
public function prettifyOnlineStatus($presence, $accounts)
{
$key = 'online_status';
if (Cache::has($key)) {
return Cache::get($key);
} else {
$user_string = '<strong>Online Status</strong><br/>';
$found = false;
foreach ($presence as $seo => $response) {
$data = json_decode($response->getBody(), true);
if (isset($data['state']) && $data['state'] == "Online") {
foreach ($data['devices'] as $device) {
if ($device['type'] == "XboxOne") {
foreach ($device['titles'] as $title) {
if (in_array($title['id'], $this->acceptedGameIds)) {
$found = true;
$gt = $accounts->where('seo', $seo)->first();
$user_string .= "<strong>" . $gt->gamertag . ": </strong>" . $title['name'];
if (isset($title['activity'])) {
$user_string .= " (" . $title['activity']['richPresence'] . ")";
}
$user_string .= "<br/>";
}
}
}
}
}
}
if (!$found) {
$user_string = 'No-one is online. Pity us.';
}
Cache::put($key, $user_string, 5);
return $user_string;
}
}
示例4: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Cache::has('session.key')) {
return redirect('/trips');
}
return $next($request);
}
示例5: latest
public function latest()
{
if ($this->isLoggedIn && $this->request->has('personal') && $this->request->get('personal') == 'true') {
$isCached = false;
$bans = $this->repository->getPersonalBans($this->user->settings()->playerIds());
} else {
$isCached = Cache::has('bans.latest');
$bans = $this->repository->getLatestBans();
}
if ($this->request->has('type') && $this->request->get('type') == 'rss') {
$feed = Feed::make();
$feed->title = sprintf('Latest Battlefield Bans by %s', Config::get('bfacp.site.title'));
$feed->description = sprintf('Latest Battlefield Bans by %s', Config::get('bfacp.site.title'));
$feed->setDateFormat('datetime');
$feed->link = URL::to('api/bans/latest?type=rss');
$feed->lang = 'en';
foreach ($bans as $ban) {
$title = sprintf('%s banned for %s', $ban['player']['SoldierName'], $ban['record']['record_message']);
$view = View::make('system.rss.ban_entry_content', ['playerId' => $ban['player']['PlayerID'], 'playerName' => $ban['player']['SoldierName'], 'banreason' => $ban['record']['record_message'], 'sourceName' => $ban['record']['source_name'], 'sourceId' => $ban['record']['source_id'], 'banReason' => $ban['record']['record_message']]);
$feed->add($title, $ban['record']['source_name'], $ban['player']['profile_url'], $ban['ban_startTime'], $title, $view->render());
}
return $feed->render('atom');
}
return MainHelper::response(['cols' => Lang::get('dashboard.bans.columns'), 'bans' => $bans], null, null, null, $isCached, true);
}
示例6: render
public function render($format = 'atom', $cache = FALSE, $cacheTime = 3600)
{
$channel = $this->channel;
$channel->pubdate = $this->formatDate($this->channel->pubdate, $format);
$items = $this->items;
foreach ($items as $item) {
$item->pubdate = $this->formatDate($item->pubdate, $format);
}
if ($format == 'atom') {
$this->content_type = 'application/atom+xml';
} else {
$this->content_type = 'application/rss+xml';
}
if ($cache == TRUE && Cache::has('feed-' . $format)) {
return response()->view('feed::' . $format, Cache::get('feed-' . $format))->header('Content-Type', $this->content_type)->header('Content-Type', 'text/xml');
} elseif ($cache == TRUE) {
Cache::put('feed-' . $format, compact('channel', 'items'), $cacheTime);
return response()->view('feed::' . $format, compact('channel', 'items'))->header('Content-Type', $this->content_type)->header('Content-Type', 'text/xml');
} elseif ($cache == FALSE && Cache::has('feed-' . $format)) {
Cache::forget('feed-' . $format);
return response()->view('feed::' . $format, compact('channel', 'items'))->header('Content-Type', $this->content_type)->header('Content-Type', 'text/xml');
} else {
return response()->view('feed::' . $format, compact('channel', 'items'))->header('Content-Type', $this->content_type)->header('Content-Type', 'text/xml');
}
}
示例7: tableToArray
/**
* Return a simple list of entries in the table.
*
* May cache the results for up to 60 minutes.
*
* @return array of Fluent objects
*/
public static function tableToArray()
{
$me = new static();
$cache_key = $me->cacheKey();
// Return the array from the cache if it is present.
if (Cache::has($cache_key)) {
return (array) Cache::get($cache_key);
}
// Otherwise put the results into the cache and return them.
$results = [];
$query = static::all();
// If the current model uses softDeletes then fix the
// query to exclude those objects.
foreach (class_uses(__CLASS__) as $traitName) {
if ($traitName == 'SoftDeletes') {
$query = static::whereNull('deleted_at')->get();
break;
}
}
/** @var Cacheable $row */
foreach ($query as $row) {
$results[$row->getIndexKey()] = $row->toFluent();
}
Cache::put($cache_key, $results, 60);
return $results;
}
示例8: profile
/**
* Shows the player profile
*
* @param integer $id
* @param string $name
*/
public function profile($id, $name = '')
{
// Cache key
$key = sprintf('player.%u', $id);
// Is there already a cached version for the player
$isCached = Cache::has($key);
// Get or Set cache for player
$player = Cache::remember($key, 5, function () use($id) {
$json = $this->repository->setopts(['ban.previous.server', 'ban.record.server', 'reputation', 'infractionsGlobal', 'infractionsServer.server', 'stats.server', 'specialGroups'], true)->getPlayerById($id)->toJson();
return json_decode($json);
});
$charts = Cache::remember(sprintf('player.%u.charts', $id), 5, function () use($id) {
$charts = [];
$charts['overview'] = new Collection(DB::select(File::get(storage_path() . '/sql/playerCommandOverview.sql'), [$id]));
$charts['spline'] = new Collection(DB::select(File::get(storage_path() . '/sql/playerCommandHistory.sql'), [$id]));
$charts['aliases'] = Record::where('command_type', 48)->where('target_id', $id)->select(DB::raw('record_message AS `player_name`, COUNT(record_id) AS `seen`'))->groupBy('player_name')->get();
$charts['iphistory'] = Record::where('command_type', 49)->where('target_id', $id)->where('record_message', '!=', 'No previous IP on record')->select(DB::raw('record_message AS `ip`, COUNT(record_id) AS `seen`'))->groupBy('ip')->get();
$charts['overview'] = $charts['overview']->map(function ($command) {
return [$command->label, intval($command->value)];
});
$charts['aliases'] = $charts['aliases']->map(function ($a) {
return [$a->player_name, intval($a->seen)];
});
$charts['iphistory'] = $charts['iphistory']->map(function ($ip) {
return [$ip->ip, intval($ip->seen)];
});
return $charts;
});
$groups = MainHelper::specialGroups($player->special_groups, 'player_group');
$page_title = !empty($player->ClanTag) ? sprintf('[%s] %s', $player->ClanTag, $player->SoldierName) : $player->SoldierName;
return View::make('player.profile', compact('player', 'page_title', 'charts', 'isCached', 'groups'));
}
示例9: isRead
/**
* Returns true/false depending if the entry
* has been marked read (exists inside the cache).
*
* @return bool
*/
public function isRead()
{
if (Cache::has($this->makeCacheKey())) {
return true;
}
return false;
}
示例10: fetchConfig
/**
* Fetch the stored config from the cache.
*
* @return mixed
*/
public function fetchConfig()
{
if (Cache::has($this->getCacheKey())) {
return Cache::get($this->getCacheKey());
}
return null;
}
示例11: currentWebsiteData
/**
* Determine the current website data.
*
* Returns null if the web site is not found in the websites table.
*
* @return array
*/
public static function currentWebsiteData()
{
static $current_data;
$BASE_URL = static::currentServerName();
$cache_key = 'website-data.' . $BASE_URL;
// Get the current ID from the cache if it is present.
if (empty($current_data)) {
if (Cache::has($cache_key)) {
return Cache::get($cache_key);
}
}
// If the cache doesn't have it then get it from the database.
if (empty($current_data)) {
// Have to do this using a raw query because Laravel doesn't INSTR.
try {
/** @var Website $result */
$result = static::whereRaw("INSTR('" . $BASE_URL . "', `http_host`) > 0")->orderBy(DB::raw('LENGTH(`http_host`)'), 'desc')->first();
if (empty($result)) {
$current_data = null;
} else {
$current_data = $result->toArray();
}
Cache::put($cache_key, $current_data, 60);
} catch (\Exception $e) {
$current_data = null;
}
}
return $current_data;
}
示例12: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!Cache::has('loginVisitor')) {
return redirect()->guest('auth/oauth/github');
}
return $next($request);
}
示例13: fire
/**
* Execute the console command.
*
* @return void
*
* @throws \Exception
*/
public function fire()
{
$uploadPath = env('UPLOAD_DIR', 'uploads');
// Use UPLOAD_DIR either as an absolute path, or relative to the base path
if (!($path = realpath($uploadPath))) {
$path = base_path($uploadPath);
}
$importedSomething = false;
foreach (scandir($path) as $file) {
if (in_array($file, ['.', '..', '.gitignore', '.gitkeep'])) {
continue;
}
$version = $this->import($file, $path);
if ($version) {
$importedSomething = true;
$identifier = $version->package->identifier;
$versionNumber = $version->name;
$this->info("Imported \"<comment>{$identifier}</comment>\" (@ {$versionNumber})");
// Make sure the directory exists
if (!file_exists(dirname($version->storagePath))) {
mkdir(dirname($version->storagePath));
}
rename($path . '/' . $file, $version->storagePath);
}
}
if ($importedSomething) {
if (Cache::has('xml.renderedPath')) {
unlink(Cache::pull('xml.renderedPath'));
}
} else {
$this->info('No files found to import.');
}
}
示例14: getTimestampMigrationName
/**
* @return string
*/
protected function getTimestampMigrationName()
{
if (!Cache::has(static::CACHENAME)) {
Cache::forever(static::CACHENAME, date('Y_m_d_His') . '_' . $this->getMigrationName());
}
return Cache::get(static::CACHENAME);
}
示例15: put
public function put(Route $route, Request $request, Response $response)
{
$key = $this->makeCacheKey($request->url());
if (!Cache::has($key)) {
Cache::put($key, $response->getContent(), 10);
}
}