本文整理汇总了PHP中Illuminate\Cache\CacheManager::rememberForever方法的典型用法代码示例。如果您正苦于以下问题:PHP CacheManager::rememberForever方法的具体用法?PHP CacheManager::rememberForever怎么用?PHP CacheManager::rememberForever使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Cache\CacheManager
的用法示例。
在下文中一共展示了CacheManager::rememberForever方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* @param $key
* @param null $default
* @return null
*/
public function get($key, $default = null)
{
try {
$settings = $this->cache->rememberForever($this->cache_key, function () {
$settings = Setting::get(['key', 'value']);
$arr = [];
foreach ($settings as $setting) {
$arr[$setting->key] = $setting->value;
}
return $arr;
});
return isset($settings[$key]) ? $settings[$key] : $default;
} catch (Exception $ex) {
return null;
}
}
示例2: fetchAndCache
/**
* Cache all configurations.
*
* @return void
*/
public function fetchAndCache()
{
$this->removeCache();
$configs = $this->cache->rememberForever('cartalyst.config', function () {
return $this->database->table($this->databaseTable)->get();
});
$cachedConfigs = [];
foreach ($configs as $key => $config) {
$value = $this->parseValue($config->value);
$cachedConfigs[$config->item] = $value;
parent::set($config->item, $value);
}
$this->cachedConfigs = $cachedConfigs;
}
示例3: rememberForever
/**
* @param $key
* @param $data
*
* @return mixed
*/
public function rememberForever($key, $data)
{
return $this->cache->rememberForever($key, function () use($data) {
return $data;
});
}