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


PHP Repository::rememberForever方法代码示例

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


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

示例1: cache

 /**
  * Cache a view. If minutes are null, the view is cached forever.
  *
  * @param array        $data
  * @param string       $view
  * @param array        $mergeData
  * @param int          $minutes
  * @param string       $key
  * @param string|array $tag
  *
  * @return string
  */
 public function cache($data, $view, $mergeData = null, $minutes = null, $key = null, $tag = null)
 {
     if (!$this->enabled) {
         return call_user_func($this->renderView($view, $data, $mergeData));
     }
     $viewKey = $this->getCacheKeyForView($view, $key);
     $mergeData = $mergeData ?: [];
     $tags = [$this->cacheKey];
     if ($tag) {
         if (!is_array($tag)) {
             $tag = [$tag];
         }
         $tags = array_merge($tags, $tag);
     }
     if ($this->cacheIsTaggable && $minutes === null) {
         return $this->cache->tags($tags)->rememberForever($viewKey, $this->renderView($view, $data, $mergeData));
     }
     if ($this->cacheIsTaggable) {
         return $this->cache->tags($tags)->remember($viewKey, $minutes, $this->renderView($view, $data, $mergeData));
     }
     if ($minutes === null) {
         return $this->cache->rememberForever($viewKey, $this->renderView($view, $data, $mergeData));
     }
     return $this->cache->remember($viewKey, $minutes, $this->renderView($view, $data, $mergeData));
 }
开发者ID:spatie,项目名称:laravel-partialcache,代码行数:37,代码来源:PartialCache.php

示例2: put

 /**
  * Put to the cache.
  *
  * @param mixed  $key
  * @param string $fragment
  */
 public function put($key, $fragment)
 {
     $key = $this->normalizeCacheKey($key);
     return $this->cache->rememberForever($key, function () use($fragment) {
         return $fragment;
     });
 }
开发者ID:patrickheppler,项目名称:matryoshka,代码行数:13,代码来源:RussianCaching.php

示例3: roles

 /**
  * @param bool $forget
  *
  * @return \Illuminate\Database\Eloquent\Collection|Role[]|null
  */
 public function roles(bool $forget = false)
 {
     if ($forget === true) {
         return $this->cache->forget(self::ROLE_KEY);
     }
     return $this->cache->rememberForever(self::ROLE_KEY, function () {
         return app(Role::class)->with('permissions')->get();
     });
 }
开发者ID:znck,项目名称:trust,代码行数:14,代码来源:Trust.php

示例4: all

 /**
  * Get the dataset collection
  *
  * @return \Illuminate\Support\Collection
  */
 public function all()
 {
     $cacheKey = 'dataset' . (new ReflectionClass($this))->getShortName();
     if ($this->cache->has($cacheKey)) {
         return $this->cache->get($cacheKey);
     }
     $dataset = $this->cache->rememberForever($cacheKey, function () {
         return $this->getDataset();
     });
     return $dataset;
 }
开发者ID:TFidryForks,项目名称:spira,代码行数:16,代码来源:Dataset.php

示例5: getComponent

 /**
  * Get a TextFormatter component.
  *
  * @param string $name "renderer" or "parser"
  * @return mixed
  */
 protected function getComponent($name)
 {
     $cacheKey = 'flarum.formatter.' . $name;
     return $this->cache->rememberForever($cacheKey, function () use($name) {
         return $this->getConfigurator()->finalize()[$name];
     });
 }
开发者ID:Luceos,项目名称:core,代码行数:13,代码来源:Formatter.php

示例6: remember

 /**
  * Get an item from the cache, or store the default value forever.
  *
  * @param  string   $key
  * @param  \Closure $callback
  * @return mixed
  */
 protected function remember($key, Closure $callback)
 {
     if (app()->environment('local')) {
         return $callback();
     }
     return $this->cache->rememberForever($key, $callback);
 }
开发者ID:hazzardweb,项目名称:docs.hazzardweb.com,代码行数:14,代码来源:Documentation.php

示例7: loadContent

 /**
  * Load content.
  *
  * @param  string  $file
  *
  * @return mixed
  */
 protected function loadContent($file)
 {
     return $this->cache->rememberForever("doc.{$file}", function () use($file) {
         $this->validateFileDoesExist($file);
         return $this->files->get($file);
     });
 }
开发者ID:stevebauman,项目名称:orchestraplatform.com,代码行数:14,代码来源:FileLoader.php

示例8: __construct

 /**
  * Initialize the Option Class
  * build the Config array.
  *
  * @param StorageContract $storage The Database Interface
  * @param CacheContract   $cache Laravel CacheContract
  */
 public function __construct(StorageContract $storage, ConfigContract $config, CacheContract $cache)
 {
     $this->storage = $storage;
     $this->cache = $cache;
     $this->config = $config;
     $this->items = $cache->rememberForever('weboap.options', function () {
         return $this->storage->all();
     });
 }
开发者ID:weboap,项目名称:option,代码行数:16,代码来源:Option.php

示例9: getCached

 /**
  * Pull the settings from the cache repository or query for it.
  *
  * @return array
  */
 protected function getCached()
 {
     $this->grabbedCache = true;
     $cached = $this->cache->rememberForever('settings', function () {
         try {
             return $this->setting->oldest('name')->pluck('value', 'name')->all();
         } catch (\PDOException $e) {
             return [];
         }
     });
     return $this->settings = array_merge($this->settings, $cached);
 }
开发者ID:flashtag,项目名称:core,代码行数:17,代码来源:Settings.php

示例10: get

 /**
  * Get the specified setting value.
  *
  * @param string $key
  * @param mixed $default
  * @return mixed
  */
 public function get($key, $default = null)
 {
     $this->fire('getting', $key, [$key, $default]);
     $generatedKey = $this->getKey($key);
     if ($this->isCacheEnabled()) {
         $repository = $this->repository;
         $value = $this->cache->rememberForever($generatedKey, function () use($repository, $generatedKey) {
             return $repository->get($generatedKey);
         });
     } else {
         $value = $this->repository->get($generatedKey, $default);
     }
     if (!is_null($value)) {
         $value = $this->unserializeValue($this->isEncryptionEnabled() ? $this->encrypter->decrypt($value) : $value);
     } else {
         $value = $default;
     }
     $this->fire('get', $key, [$key, $value, $default]);
     $this->context(null);
     return $value;
 }
开发者ID:sylarbg,项目名称:settings,代码行数:28,代码来源:Settings.php

示例11: render

 /**
  * Render the document.
  *
  * This will run all document:render hooks and then return the
  * output. Should be called within a view.
  *
  * @return string
  */
 public function render()
 {
     if ($this->rendered) {
         return $this->content;
     }
     // todo implement this. if changes are made that influence the attributes (ex, the project config), the cache should drop.
     // this is a example of how to create a unique hash for it. not sure if it would work out
     //        $attributesChanged = md5(collect(array_dot($this->attributes))->values()->transform(function ($val) {
     //            return md5((string)$val);
     //        })->implode('.'));
     $this->codex->dev->benchmark('document');
     $this->hookPoint('document:render');
     if ($this->shouldCache()) {
         $minutes = $this->getCodex()->config('document.cache.minutes', null);
         if ($minutes === null) {
             $lastModified = (int) $this->cache->rememberForever($this->getCacheKey(':last_modified'), function () {
                 return 0;
             });
         } else {
             $lastModified = (int) $this->cache->remember($this->getCacheKey(':last_modified'), $minutes, function () {
                 return 0;
             });
         }
         if ($this->lastModified !== $lastModified || $this->cache->has($this->getCacheKey()) === false) {
             $this->runProcessors();
             $this->cache->put($this->getCacheKey(':last_modified'), $this->lastModified, $minutes);
             $this->cache->put($this->getCacheKey(':content'), $this->content, $minutes);
         } else {
             $this->content = $this->cache->get($this->getCacheKey(':content'));
         }
     } else {
         $this->runProcessors();
     }
     $this->rendered = true;
     $this->hookPoint('document:rendered');
     $this->codex->dev->addMessage($this->toArray());
     $this->codex->dev->stopBenchmark(true);
     return $this->content;
 }
开发者ID:codexproject,项目名称:core,代码行数:47,代码来源:Document.php

示例12: getPublished

 /**
  * Get all published navigation.
  *
  * @return \Illuminate\Database\Eloquent\Collection|static[]
  */
 public function getPublished()
 {
     return $this->cache->rememberForever('navigation.published', function () {
         return $this->repository->getPublished();
     });
 }
开发者ID:yajra,项目名称:cms-core,代码行数:11,代码来源:CacheRepository.php

示例13: cacheRememberForever

 /**
  * Remember the result value for a closure forever
  * @param $key
  * @param $callback
  *
  * @return mixed
  */
 public function cacheRememberForever($key, $callback)
 {
     return $this->cache->rememberForever($this->cachePrefix($key), $callback);
 }
开发者ID:micfai,项目名称:laravel-slack-api,代码行数:11,代码来源:SlackMethod.php

示例14: all

 /**
  * Get all the setting entries.
  *
  * @return \Illuminate\Database\Eloquent\Collection
  */
 public function all()
 {
     return !$this->isCached() ? $this->model->all() : $this->cache->rememberForever($this->getCacheKey(), function () {
         return $this->model->all();
     });
 }
开发者ID:ARCANESOFT,项目名称:Settings,代码行数:11,代码来源:EloquentStore.php

示例15: getPermissions

 /**
  * Get the current permissions.
  *
  * @return \Illuminate\Database\Eloquent\Collection
  */
 protected function getPermissions()
 {
     return $this->cache->rememberForever($this->cacheKey, function () {
         return app(Permission::class)->with('roles')->get();
     });
 }
开发者ID:austinkregel,项目名称:corrections,代码行数:11,代码来源:PermissionRegistrar.php


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