当前位置: 首页>>代码示例>>PHP>>正文


PHP Cache::put方法代码示例

本文整理汇总了PHP中Illuminate\Support\Facades\Cache::put方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::put方法的具体用法?PHP Cache::put怎么用?PHP Cache::put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\Facades\Cache的用法示例。


在下文中一共展示了Cache::put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
     }
 }
开发者ID:GMSteuart,项目名称:PandaLove,代码行数:35,代码来源:Client.php

示例2: schedule

 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->call(function () {
         Cache::put('last-cron', new Carbon(), 5);
     })->everyMinute();
     $schedule->command('inspire')->hourly();
 }
开发者ID:atrauzzi,项目名称:laravel-drydock,代码行数:13,代码来源:Kernel.php

示例3: 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;
 }
开发者ID:delatbabel,项目名称:keylists,代码行数:33,代码来源:Cacheable.php

示例4: compose

 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     if (!Cache::get('popular_categories')) {
         Cache::put('popular_categories', $this->categories->getPopular(), 60);
     }
     $view->with('popular_categories', Cache::get('popular_categories'));
 }
开发者ID:ambarsetyawan,项目名称:brewski,代码行数:13,代码来源:PopularCategoriesComposer.php

示例5: handle

 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     // Session used to check roles inside the views
     //FIRST :: SESSION(ROLE.ID)
     // SECOND CACHE(MODULES.ID
     // THIRD :: CACHE(ABILITIES.ID
     // FOURTH  CACHE(AUTHOR/ADMIN/EDITOR.ID
     // FIFTH CACHE(ROLE.ID
     $this->userRoles = $this->user->roles()->first();
     $authUserRole = $this->user->roles()->first();
     Session::put('ROLE.' . Auth::id(), $authUserRole->id);
     Session::put('ROLE.' . $authUserRole->name, md5($authUserRole->id));
     $modules = $this->userRoles->perms()->where('level', '=', '1');
     $modulesList = $modules->lists('name', 'id')->toArray();
     // abilitiles = modules + permissions
     $abilities = $this->userRoles->perms()->get();
     $abilitiesList = $abilities->Lists('name', 'id')->toArray();
     // ROLE.AUTHOR/ADMIN/EDITOR
     Cache::put(strtoupper($authUserRole->name) . Auth::id(), $authUserRole->name, 99999999);
     // GET USER ROLE
     Cache::put('ROLE.' . Auth::id(), $authUserRole->name, 99999999);
     /*
      * 'Module.ID' => [List of Modules]
      * */
     Cache::put('MODULES.' . Auth::id(), array_values($modulesList), 99999999);
     /*
      * All Permissions and Roles in one array
      *
      * */
     Cache::put('ABILITIES.' . Auth::id(), array_values($abilitiesList), 99999999);
 }
开发者ID:uusa35,项目名称:ebook,代码行数:36,代码来源:CollectCacheDataForAuthUser.php

示例6: 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);
     }
 }
开发者ID:RichJones22,项目名称:TimeTrax,代码行数:7,代码来源:CacheFilters.php

示例7: 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');
     }
 }
开发者ID:zogxray,项目名称:simple-laravel-feed,代码行数:25,代码来源:Feed.php

示例8: compose

 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     if (!Cache::get('recent_posts')) {
         Cache::put('recent_posts', $this->posts->getAll('published', null, 'published_at', 'desc', 5), 10);
     }
     $view->with('recent_posts', Cache::get('recent_posts'));
 }
开发者ID:ambarsetyawan,项目名称:brewski,代码行数:13,代码来源:RecentPostsComposer.php

示例9: generateCache

 public static function generateCache($public_key, \AccessLevel $accessLevel)
 {
     $expiresAt = self::generateExpiration($accessLevel->interval_type, $accessLevel->interval_value);
     // if no cache, create one with total and remain as the same
     $cache = ['total' => $accessLevel->request_limit, 'remaining' => $accessLevel->request_limit, 'expires_at' => $expiresAt->toDateTimeString()];
     Cache::put($public_key, json_encode($cache), 0);
 }
开发者ID:ryanmcoble,项目名称:remedy,代码行数:7,代码来源:RateLimiter.php

示例10: installK2

 public function installK2(StoreK2Request $request, MessagingResource $resource)
 {
     // TODO: this cannot be hardcoded, depends on resource type
     // Also make sure that by injecting a crafted resource id it won't be possible to override other keys!
     Cache::put("K2_SLOT_" . $resource->getResourceId(), $request->k2->toJson(), 0);
     return response(null, 204);
 }
开发者ID:nicolacimmino,项目名称:RIoT,代码行数:7,代码来源:KeysController.php

示例11: blacklist

 public function blacklist()
 {
     if (!$this->isBlacklisted()) {
         $expiresAt = Carbon::createFromTimestamp($this->get()->exp);
         Cache::put($this->jti(), $this->jti(), $expiresAt);
         $this->status = self::BLACKLISTED_TOKEN;
     }
 }
开发者ID:lucasromanojf,项目名称:jwt-guard,代码行数:8,代码来源:CommonJWT.php

示例12: updateSessionCookie

 /**
  * 更新缓存cookie
  * @param $setCookies
  */
 public function updateSessionCookie($setCookies)
 {
     $cacheCookie = $this->getSessionCookie();
     $setCookie = str_replace(' ', '+', $this->getSetCookie($setCookies));
     $mergeCookie = $this->cookieStr2Arr($setCookie) + $this->cookieStr2Arr($cacheCookie);
     $newCookie = $this->cookieArr2Str($mergeCookie);
     Cache::put($this->getCacheKey(), $newCookie, PazxConst::CACHE_EXPIRES_MINUTES);
 }
开发者ID:zhangzijun,项目名称:diandian,代码行数:12,代码来源:Session.php

示例13: remember

 public static function remember($key, $callback)
 {
     if (!Cache::has($key)) {
         $value = $callback();
         Cache::put($key, $value, 60);
     }
     return Cache::get($key);
 }
开发者ID:kcwikizh,项目名称:kcwiki-api,代码行数:8,代码来源:Util.php

示例14: put

 public function put($key, $data, $cacheMinutes = null)
 {
     if (!$cacheMinutes) {
         $cacheMinutes = self::CACHE_MINUTES;
     }
     $expiresAt = Carbon::now()->addMinutes($cacheMinutes);
     Cache::put($key, $data, $expiresAt);
 }
开发者ID:samhoud,项目名称:eventbrite-plugin,代码行数:8,代码来源:EventbriteCache.php

示例15: handle

 /**
  * After request. If the cache key not exist. Cache the contents
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $response = $next($request);
     $key = $this->makeCacheKey($request->url());
     if (!Cache::has($key)) {
         Cache::put($key, $response->getContent(), 60);
     }
     return $response;
 }
开发者ID:lihaoxiang1989,项目名称:Marlabs-notes,代码行数:16,代码来源:AfterCache.php


注:本文中的Illuminate\Support\Facades\Cache::put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。