本文整理汇总了PHP中Illuminate\Cache\Repository::remember方法的典型用法代码示例。如果您正苦于以下问题:PHP Repository::remember方法的具体用法?PHP Repository::remember怎么用?PHP Repository::remember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Cache\Repository
的用法示例。
在下文中一共展示了Repository::remember方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cache
/**
* Get info from a specify url and cache that using laravel cache manager.
*
* @param string $url
* @param null|array $options
* @return mixed
*/
public function cache($url, array $options = null)
{
$lifetime = array_get($options, 'lifetime', 60);
array_forget($options, 'lifetime');
$self = $this;
return $this->cache->remember($url, $lifetime, function () use($self, $url, $options) {
return $self->get($url, $options);
});
}
示例2: cached
/**
* Returns the cached content if NOT running locally.
*
* @param string $key
* @param mixed $value
* @param int $time
* @return mixed
*/
private function cached($key, $value, $time = 5)
{
if (App::environment('local') === false) {
return $this->cache->remember($key, $time, function () use($value) {
return $value;
});
} else {
return $value;
}
}
示例3: getColumnsOnCache
/**
* To get all columns on caching
*
* @param \Illuminate\Database\Eloquent\Model $model
* @return array
*/
protected function getColumnsOnCache(Model $model)
{
/**
* In normal scenario tables and columns often is not changed.
* Therefore every time it is not need to access the database for knowing
* columns name. We don't want make preoccupy/busy to the database.
*/
$fullKey = $this->getFullName($model);
return $this->cache->remember($fullKey, $this->getRememberTime(), function () use($model) {
return $this->builder->getColumnListing($model->getTable());
});
}
示例4: data
protected function data()
{
if (!$this->loaded) {
$this->data = $this->original = $this->cache->remember('fluxbb.config', 24 * 60, function () {
$data = $this->database->table('config')->get();
$cache = array();
foreach ($data as $row) {
$cache[$row->conf_name] = $row->conf_value;
}
return $cache;
});
$this->loaded = true;
}
return $this->data;
}
示例5: remember
/**
* Get an item from the cache, or store the default value.
*
* @param string $key
* @param \DateTime|int $minutes
* @param \Closure $callback
*
* @return mixed
*/
public function remember($key, $minutes, Closure $callback)
{
if ($this->enabled) {
return $this->cache->remember($key, $minutes, $callback);
}
return $callback;
}
示例6: retrieveByReference
/**
* Retrieve a model object by its reference value, if it has one
*
* @param $reference
* @return null
*/
public function retrieveByReference($reference)
{
$referenceColumn = $this->referenceIdColumnName();
if ($this->model->isFillable($referenceColumn)) {
$key = $this->resourceName . '.' . $referenceColumn . '.' . $reference;
return $this->cache->remember($key, 10, function () use($reference) {
return $this->model->where($this->referenceIdColumnName(), $reference)->first();
});
} else {
return null;
}
}
示例7: remember
/**
* Get an item from the cache, or store the default value.
*
* @param string $key
* @param \DateTime|int $minutes
* @param \Closure $callback
* @return mixed
* @static
*/
public static function remember($key, $minutes, $callback)
{
return \Illuminate\Cache\Repository::remember($key, $minutes, $callback);
}
示例8: remember
/**
* Get an item from the cache, or store the default value.
*
* @param mixed $key
* @param \DateTime|int $minutes
* @param \Closure $callback
* @return mixed
*/
public function remember($key, $minutes, Closure $callback)
{
if (is_array($key)) {
return $this->rememberMany($key, $minutes, $callback);
}
return parent::remember($key, $minutes, $callback);
}
示例9: getCachedLangModels
/**
* To get all lang models on the cache driver
*
* @return \Illuminate\Database\Eloquent\Collection
*/
protected function getCachedLangModels()
{
$key = $this->getKeyOfCachedLangModel($this->getMainModel()->langModels()->getRelated());
return $this->cache->remember($key, $this->getRememberTime(), function () {
return $this->getAllLangModels()->getRelated()->all();
});
}
示例10: fetch
/**
* @author Rohit Arora
*
* @param array $columns
*
* @return Collection
*/
public function fetch($columns = [ALL_FIELDS])
{
return $this->Cache->remember('posts-' . implode('-', $columns), 60, function () use($columns) {
return $this->PostContract->fetch($columns);
});
}