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


PHP Cache::remember方法代码示例

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


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

示例1: compose

 /**
  * Compose the view.
  *
  * @return void
  */
 public function compose(View $view)
 {
     $value = Cache::remember('users', 3, function () {
         return DB::table('users')->get();
     });
     $view->with('tags', Tags::all())->with('categories', Category::all());
 }
开发者ID:lyovkin,项目名称:v2board,代码行数:12,代码来源:LeftAsideComposer.php

示例2: cachedPermissions

 /**
  * Tries to return all the cached permissions of the user
  * and if it can't bring the permissions from the cache,
  * it would bring them back from the DB
  * @return Illuminate\Database\Eloquent\Collection
  */
 public function cachedPermissions()
 {
     $cacheKey = 'laratrust_permissions_for_user_' . $this->getKey();
     return Cache::remember($cacheKey, Config::get('cache.ttl', 60), function () {
         return $this->permissions()->get();
     });
 }
开发者ID:santigarcor,项目名称:laratrust,代码行数:13,代码来源:LaratrustUserTrait.php

示例3: getContactInfo

 function getContactInfo()
 {
     $contactInfo = Cache::remember('contactusInfo', 20, function () {
         return $this->first();
     });
     return $contactInfo;
 }
开发者ID:uusa35,项目名称:ebook,代码行数:7,代码来源:Contactus.php

示例4: karma

 public static function karma()
 {
     $value = Cache::remember('statistics_karma', 5, function () {
         return Vote::count();
     });
     return $value;
 }
开发者ID:PovilasLT,项目名称:maze,代码行数:7,代码来源:Statistics.php

示例5: popular

 public static function popular()
 {
     $populardata = Cache::remember('popular', 60, function () {
         $data = Content::take(15)->orderBy('pageview', 'desc')->get();
         return $data;
     });
     return $populardata;
 }
开发者ID:berkcekisbas,项目名称:belirtileri,代码行数:8,代码来源:Layout.php

示例6: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     $key = $this->buildCacheKey($request);
     return Cache::remember($key, static::CACHE_MINUTES, function () use($request, $next) {
         return $next($request);
     });
 }
开发者ID:hussainweb,项目名称:drupal-stats,代码行数:14,代码来源:CacheMiddleware.php

示例7: getActions

 /**
  * Actions allowed to be used on reports
  *
  * @return array
  */
 public function getActions()
 {
     $actions = Cache::remember('system.adkats.reports.actions', 60 * 12, function () {
         return Command::whereIn('command_id', static::$allowedCommands)->lists('command_name', 'command_id');
     });
     return $actions;
 }
开发者ID:BP4U,项目名称:BFAdminCP,代码行数:12,代码来源:ReportRepository.php

示例8: getLatestBans

 /**
  * Gets the latest bans
  * @param  string  $cacheKey Caching key to use
  * @param  integer $ttl      Cache for X minutes
  * @return array
  */
 public function getLatestBans($cacheKey = 'bans.latest', $ttl = 1)
 {
     $bans = Cache::remember($cacheKey, $ttl, function () {
         return Ban::with('player', 'record')->latest(30)->get()->toArray();
     });
     return $bans;
 }
开发者ID:R3alflash,项目名称:BFAdminCP,代码行数:13,代码来源:BanRepository.php

示例9: index

 /**
  * Create or update a note
  *
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse
  */
 public function index(Request $request)
 {
     $linehaul = $request->input('linehaul', null);
     $postalCode = $request->input('postalcode', null);
     $fresh = $request->input('fresh', false);
     $dummy = $request->input('dummy', false);
     //Damn strings
     if ($fresh == 'false') {
         $fresh = false;
     }
     if ($fresh) {
         $postalCodes = $this->getPostalCodes($linehaul, $postalCode);
     } else {
         $postalCodes = Cache::remember('postal_codes', 24 * 60, function () use($linehaul, $postalCode) {
             return $this->getPostalCodes($linehaul, $postalCode);
         });
     }
     if (!$dummy) {
         return Excel::create('PostalCodes' . Carbon::now()->toDateString(), function ($excel) use($postalCodes) {
             $excel->sheet('postalcodes', function ($sheet) use($postalCodes) {
                 $sheet->fromArray($postalCodes);
             });
         })->download('xls');
     }
     return 'DB UPDATED';
 }
开发者ID:dagmawiyehenew,项目名称:laravel-levapp,代码行数:32,代码来源:PostalCodeController.php

示例10: compose

 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $user = Cache::remember('user', 1440, function () {
         return Auth::user();
     });
     $view->with('user', $user);
 }
开发者ID:jespersgaard,项目名称:tyloo,代码行数:13,代码来源:LoggedInUserViewComposer.php

示例11: fetchAll

 public function fetchAll()
 {
     $result = Cache::remember('post_cache', 1, function () {
         return $this->get();
     });
     return $result;
 }
开发者ID:onerciller,项目名称:Laravel-es-redis-example,代码行数:7,代码来源:Post.php

示例12: cachedRoles

 /**
  * Tries to return all the cached roles of the user
  * and if it can't bring the roles from the cache,
  * it would bring them back from the DB
  * @return Illuminate\Database\Eloquent\Collection
  */
 public function cachedRoles()
 {
     $cacheKey = 'lumineer_roles_for_user_' . $this->getKey();
     return Cache::remember($cacheKey, Config::get('cache.ttl', 60), function () {
         return $this->roles()->get();
     });
 }
开发者ID:19peaches,项目名称:lumineer,代码行数:13,代码来源:LumineerUserTrait.php

示例13: remember

 /**
  * Returns cached data after updating the cached value if expired
  *
  * @param  string  $key
  * @param  int     $ttl
  * @param  closure $closure
  * @return mixed
  */
 public static function remember($key, $ttl, $closure)
 {
     if (!isset(static::$cache[$key])) {
         static::$cache[$key] = parent::remember($key, $ttl, $closure);
     }
     return static::$cache[$key];
 }
开发者ID:carriercomm,项目名称:sticky-notes,代码行数:15,代码来源:Cache.php

示例14: init

 /**
  * Init blogit.
  *
  * Fetch all files on the Github repository, transform and store them into
  * a collection of articles.
  *
  * @return void
  */
 protected function init()
 {
     if (config('blogit.cache')) {
         $documents = Cache::remember('documents', config('blogit.cache_expiration'), function () {
             return $this->documents->getAll();
         });
     } else {
         $documents = $this->documents->getAll();
     }
     // Make and push the new article into the collection.
     foreach ($documents as $document) {
         if (config('blogit.cache')) {
             $article = Cache::remember($document['sha'], config('blogit.cache_expiration'), function () use($document) {
                 return $this->makeArticle($document['path']);
             });
         } else {
             $article = $this->makeArticle($document['path']);
         }
         $this->collection->push($article);
     }
     // Set the previous and next articles for each article.
     $this->collection = $this->collection->each(function ($article, $key) {
         if (($previous = $this->collection->get($key - 1)) instanceof Article) {
             $article->setPrevious($previous);
         }
         if (($next = $this->collection->get($key + 1)) instanceof Article) {
             $article->setNext($next);
         }
     });
     // Set the related articles for each article.
     $this->collection = $this->collection->each(function ($article) {
         $related = $this->getRelatedArticlesByTags($article);
         $article->setRelatedArticles($related);
     });
 }
开发者ID:jrean,项目名称:blogit,代码行数:43,代码来源:Blogit.php

示例15: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $fabricantes = Cache::remember('fabricantes', 15 / 60, function () {
         return Fabricante::simplePaginate(15);
     });
     return response()->json(['siguiente' => $fabricantes->nextPageUrl(), 'anterior' => $fabricantes->previousPageUrl(), 'datos' => $fabricantes->items()], 200);
 }
开发者ID:osvaldino,项目名称:RESTful-API,代码行数:12,代码来源:FabricanteController.php


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