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


PHP Cache::rememberForever方法代码示例

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


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

示例1: rememberForever

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

示例2: boot

 /**
  * Bootstrap the application services.
  */
 public function boot()
 {
     parent::boot();
     $this->publishMigrations();
     $app = $this->app;
     if ($app->bound('form')) {
         $app->form->macro('selectCountry', function ($name, $selected = null, $options = []) use($app) {
             $countries = Cache::rememberForever('brianfaust.countries.select.name.cca2', function () {
                 $records = Country::get(['name', 'cca2']);
                 $countries = new Collection();
                 $records->map(function ($item) use(&$countries) {
                     $countries[$item['cca2']] = $item['name']['official'];
                 });
                 return $countries->sort();
             });
             return $app->form->select($name, $countries, $selected, $options);
         });
         $app->form->macro('selectCountryWithId', function ($name, $selected = null, $options = []) use($app) {
             $countries = Cache::rememberForever('brianfaust.countries.select.id.cca2', function () {
                 $records = Country::get(['name', 'id']);
                 $countries = new Collection();
                 $records->map(function ($item) use(&$countries) {
                     $countries[$item['id']] = $item['name']['official'];
                 });
                 return $countries->sort();
             });
             return $app->form->select($name, $countries, $selected, $options);
         });
     }
 }
开发者ID:DraperStudio,项目名称:Laravel-Countries,代码行数:33,代码来源:CountriesServiceProvider.php

示例3: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $system = Cache::rememberForever('systemSetting', function () {
         return (object) $this->settingRepository->first()->toArray();
     });
     return view('dashboard.system_setting.index', compact('system'));
 }
开发者ID:axex,项目名称:kratos,代码行数:12,代码来源:AdminSystemSettingController.php

示例4: getAllTagsForContentType

 public function getAllTagsForContentType($contentType)
 {
     return Cache::rememberForever('tags_all_content_type_' . $contentType, function () use($contentType) {
         $contentTypeId = $this->getContentTypeId($contentType);
         $hashIdsForContentTypeId = $this->getHashIdsForContentTypeId($contentTypeId);
         $distinctTags = $this->getDistinctTagsFromHashIds($hashIdsForContentTypeId);
         return $distinctTags;
     });
 }
开发者ID:utkarshx,项目名称:bluecarrot,代码行数:9,代码来源:Tags.php

示例5: get

 public function get()
 {
     if (!Cache::has('settings')) {
         Cache::rememberForever('settings', function () {
             return $this->setting->first();
         });
     }
     return Cache::get('settings');
 }
开发者ID:ringwoodinternet,项目名称:core,代码行数:9,代码来源:SettingsInjection.php

示例6: compose

 /**
  * @param View $view
  */
 public function compose(View $view)
 {
     if (!Cache::has('this_user')) {
         Cache::rememberForever('this_user', function () {
             return $this->user->thisUser($this->auth->user()->id);
         });
     }
     $view->with('user', Cache::get('this_user'));
 }
开发者ID:ringwoodinternet,项目名称:core,代码行数:12,代码来源:UserMenuViewComposer.php

示例7: provider

 public function provider()
 {
     return function ($app) {
         $parsedRoutes = Cache::rememberForever('haljson.mapping', function () use($app) {
             return $this->parseRoutes(new Mapper($app['config']->get('haljson')));
         });
         return new HalJsonSerializer(new HalJsonTransformer($parsedRoutes));
     };
 }
开发者ID:nilportugues,项目名称:laravel5-hal-json,代码行数:9,代码来源:Laravel51Provider.php

示例8: getRoleId

 public function getRoleId()
 {
     if (!Cache::has('role_id')) {
         Cache::rememberForever('role_id', function () {
             return $this->auth->user() !== null ? $this->user->getRoleId($this->auth->user()->id) : 0;
         });
     }
     Cache::get('role_id');
 }
开发者ID:ringwoodinternet,项目名称:core,代码行数:9,代码来源:MasterPageViewComposer.php

示例9: register

 /**
  * Register the service provider.
  */
 public function register()
 {
     $this->mergeConfigFrom(__DIR__ . self::PATH, 'haljson');
     $this->app->singleton(\NilPortugues\Laravel5\HalJsonSerializer\HalJsonSerializer::class, function ($app) {
         $mapping = $app['config']->get('haljson');
         $key = \md5(\json_encode($mapping));
         return Cache::rememberForever($key, function () use($mapping) {
             return new HalJsonSerializer(new HalJsonTransformer(self::parseRoutes(new Mapper($mapping))));
         });
     });
 }
开发者ID:jonphipps,项目名称:laravel5-hal-json-transformer,代码行数:14,代码来源:Laravel5HalJsonSerializerServiceProvider.php

示例10: register

 /**
  * Register the service provider.
  */
 public function register()
 {
     $this->mergeConfigFrom(__DIR__ . self::PATH, 'jsonapi');
     $this->app->singleton(JsonApiSerializer::class, function ($app) {
         $mapping = $app['config']->get('jsonapi');
         $key = md5(json_encode($mapping));
         return Cache::rememberForever($key, function () use($mapping) {
             return new JsonApiSerializer(new JsonApiTransformer(self::parseRoutes(new Mapper($mapping))));
         });
     });
 }
开发者ID:Braunson,项目名称:laravel5-jsonapi-transformer,代码行数:14,代码来源:Laravel5JsonApiServiceProvider.php

示例11: selectCountryWithId

 public function selectCountryWithId($app)
 {
     $app->form->macro('selectCountryWithId', function ($name, $selected = null, $options = []) use($app) {
         $countries = Cache::rememberForever('brianfaust.countries.select.id.cca2', function () {
             return Models\Country::get(['name', 'id'])->mapWithKeys(function ($item) {
                 return [$item['id'] => $item['name']['common']];
             })->sort();
         });
         return $app->form->select($name, $countries, $selected, $options);
     });
 }
开发者ID:draperstudio,项目名称:laravel-countries,代码行数:11,代码来源:Macros.php

示例12: provider

 public function provider()
 {
     return function ($app) {
         if (config('app.debug')) {
             $parsedRoutes = $this->parseRoutes(new Mapper($app['config']->get('jsonapi')));
         } else {
             $parsedRoutes = Cache::rememberForever('jsonapi.mapping', function () use($app) {
                 return $this->parseRoutes(new Mapper($app['config']->get('jsonapi')));
             });
         }
         return new JsonApiSerializer(new JsonApiTransformer($parsedRoutes));
     };
 }
开发者ID:nilportugues,项目名称:laravel5-jsonapi,代码行数:13,代码来源:Laravel51Provider.php

示例13: refreshLanguage

 private function refreshLanguage()
 {
     $language = App::make(LanguageInterface::class);
     $key = 'default_language';
     Cache::forget($key);
     Cache::rememberForever($key, function () use($language) {
         return $language->whereDefault(1)->firstOrFail();
     });
     $key = 'active_languages';
     Cache::forget($key);
     Cache::rememberForever($key, function () use($language) {
         return $language->whereActive(1)->get();
     });
 }
开发者ID:xavierauana,项目名称:events,代码行数:14,代码来源:RefreshCacheEventListener.php

示例14: cache

 /**
  * Retrieve from cache if not empty, otherwise store results
  * of query in cache
  *
  * @param  string   $key
  * @param  Builder  $query
  * @param  string   $verb Optional Builder verb to execute query
  *
  * @return Collection|Model|array|null
  */
 protected function cache($key, Builder $query, $verb = 'get')
 {
     $actualKey = $this->indexKey($key);
     $fetchData = function () use($actualKey, $query, $verb) {
         $this->log('refreshing cache for ' . get_class($this) . ' (' . $actualKey . ')');
         return $this->callQueryVerb($query, $verb);
     };
     if ($this->enableCaching) {
         if ($this->cacheForMinutes > 0) {
             return CacheFacade::remember($actualKey, $this->cacheForMinutes, $fetchData);
         }
         return CacheFacade::rememberForever($actualKey, $fetchData);
     }
     return $fetchData();
 }
开发者ID:stevenmaguire,项目名称:laravel-cache,代码行数:25,代码来源:EloquentCacheTrait.php

示例15: __construct

 public function __construct()
 {
     $this->client = new \Google_Client();
     $this->client->setClientId($this->ClientId);
     $this->client->setClientSecret($this->ClientSecret);
     $this->client->refreshToken($this->refreshToken);
     $this->service = new \Google_Service_Drive($this->client);
     // we cache the id to avoid having google creating
     // a new folder on each time we call it,
     // because google drive works with 'id' not 'name'
     // & thats why u could have duplicated folders under the same name
     Cache::rememberForever('folder_id', function () {
         return $this->create_folder();
     });
     $this->folder_id = Cache::get('folder_id');
 }
开发者ID:nao-pon,项目名称:flysystem-google-drive,代码行数:16,代码来源:GoogleUpload.php


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