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


PHP Cache::rememberForever方法代码示例

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


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

示例1: setting

/**
 * Get setting
 *
 * @param $name
 * @return mixed
 */
function setting($name)
{
    $settings = Cache::rememberForever('settings', function () {
        return Setting::select('name', 'value')->get();
    });
    return $settings->where('name', $name)->first();
}
开发者ID:angelWendy,项目名称:streamlet,代码行数:13,代码来源:helpers.php

示例2: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $json = \Cache::rememberForever('categories_json', function () {
         return ['data' => ['categories' => Category::categoryAsc()->get()]];
     });
     return \Response::json($json);
 }
开发者ID:nekonekonik,项目名称:nuswhispers,代码行数:12,代码来源:CategoriesController.php

示例3: setupReports

 protected function setupReports($view)
 {
     $reportsCount = Cache::rememberForever('reportsCount', function () {
         return Report::count();
     });
     $view->with('reportsCount', $reportsCount);
 }
开发者ID:Lord-Simon,项目名称:MangaIndex,代码行数:7,代码来源:GlobalComposer.php

示例4: getOrderBy

 public static function getOrderBy()
 {
     $tagsOrderBy = Cache::rememberForever('tagsOrderBy', function () {
         return ['id', 'asc'];
     });
     return $tagsOrderBy;
 }
开发者ID:shinichi81,项目名称:Nifty-Newsletter,代码行数:7,代码来源:Tag.php

示例5: index

 public function index()
 {
     $gioithieu = Cache::rememberForever('gioithieu_cache', function () {
         return $this->model->gioithieu();
     });
     return View::make('pages.gioithieu')->with(compact('gioithieu'));
 }
开发者ID:minhliem86,项目名称:liemphan-cms,代码行数:7,代码来源:GioithieuController.php

示例6: middleOfTheWorld

 public function middleOfTheWorld()
 {
     $tour = Cache::rememberForever('middleOfTheWorld', function () {
         return Tour::first();
     });
     //$tour = Tour::first();
     return View::make('tours.middle-of-the-world', compact('tour'));
 }
开发者ID:seivad,项目名称:nnt,代码行数:8,代码来源:ToursController.php

示例7: profileImage

 function profileImage($id, $width = 128, $height = 128)
 {
     $image = \Cache::rememberForever("userprofile-{$id}-{$width}-x-{$height}", function () use($id, $width, $height) {
         $img = DataSource::keystone_exec("_layouts/StPeters.Keystone/_shared/avatarhandler.ashx?id={$id}&w={$width}&h={$height}");
         return $img;
     });
     return \Response::make($image, 200, array('content-type' => 'image/jpg'));
 }
开发者ID:oeed,项目名称:Keystone-Next,代码行数:8,代码来源:FeedController.php

示例8: index

 public function index()
 {
     $contact = Cache::rememberForever('contact_cache', function () {
         return $this->model->contact();
     });
     $map = $this->model->contact_map();
     $map = json_decode($map);
     return View::make('pages.lienhe')->with(compact('contact', 'map'));
 }
开发者ID:minhliem86,项目名称:liemphan-cms,代码行数:9,代码来源:LienheController.php

示例9: compose

 public function compose(View $view)
 {
     if (!config('administr.hasLanguages')) {
         return;
     }
     $languages = \Cache::rememberForever('languages_list', function () {
         return Language::pluck('code', 'id');
     });
     $view->with('languages', $languages);
 }
开发者ID:administrcms,项目名称:administr,代码行数:10,代码来源:LanguageComposer.php

示例10: zedx_cache

 /**
  * Cache a closure forever.
  *
  * @param string   $key
  * @param \Closure $next
  *
  * @return \Closure
  */
 function zedx_cache($key, Closure $next)
 {
     if (!env('APP_CACHE', true)) {
         return $next();
     }
     return Cache::rememberForever("zx-{$key}", function () use($next) {
         \Log::info('yes');
         return $next();
     });
 }
开发者ID:zedx,项目名称:core,代码行数:18,代码来源:helpers.php

示例11: loadCategories

 public function loadCategories()
 {
     $categories = null;
     if (\Cache::has(Category::cache_key)) {
         $categories = \Cache::get(Category::cache_key);
     } else {
         $categories = \Cache::rememberForever(Category::cache_key, function () {
             return Category::lists('title', 'slug');
         });
     }
     \View::share('app_categories', $categories);
 }
开发者ID:spiritwild,项目名称:9gagvn,代码行数:12,代码来源:FrontendController.php

示例12: names

 protected function names()
 {
     $cache_id = 'emoji-names';
     $loader = function () {
         $dir = app('path.public') . self::PATH;
         foreach (glob($dir . '/*.png') as $file) {
             $names[] = pathinfo($file, PATHINFO_FILENAME);
         }
         return $names;
     };
     if ('production' == App::environment()) {
         return Cache::rememberForever($cache_id, $loader);
     } else {
         return call_user_func($loader);
     }
 }
开发者ID:a11enwong,项目名称:pochika,代码行数:16,代码来源:EmojiPlugin.php

示例13: config

 /**
  * Gets or sets the site configuration data
  *
  * @access public
  * @param  string  $group
  * @param  array   $newData
  * @return stdClass|bool
  */
 public static function config($group = '', $newData = FALSE)
 {
     // Get a config value
     if ($newData === FALSE) {
         $config = Cache::rememberForever('site.config', function () {
             $config = Config::get('default');
             if (Schema::hasTable('config')) {
                 $siteConfig = Site::all();
                 if (!is_null($siteConfig)) {
                     foreach ($siteConfig as $item) {
                         $config[$item['group']]->{$item}['key'] = $item['value'];
                     }
                 }
             }
             return $config;
         });
         return empty($group) ? (object) $config : $config[$group];
     } else {
         $site = static::config('general');
         // Get the tags that have HTML content
         $htmlKeys = preg_split('/\\||,/', $site->htmlKeys);
         // Update the new config values in the DB
         foreach ($newData as $key => $value) {
             // Check for and strip HTML content
             if (in_array($key, $htmlKeys)) {
                 $value = strip_tags($value, $site->allowedTags);
             }
             // Save config data
             if (!empty($key) and !starts_with($key, '_')) {
                 $key = camel_case($key);
                 // Get the existing value of the config
                 $config = static::query();
                 $config->where('group', $group);
                 $config->where('key', $key);
                 // Do an UPSERT, i.e. if the value exists, update it.
                 // If it doesn't, insert it.
                 if ($config->count() > 0) {
                     $config->update(array('value' => $value));
                 } else {
                     $config->insert(array('group' => $group, 'key' => $key, 'value' => $value));
                 }
             }
         }
         Cache::flush();
         return TRUE;
     }
 }
开发者ID:carriercomm,项目名称:sticky-notes,代码行数:55,代码来源:Site.php

示例14: globalParams

 function globalParams($key = null, $default = false)
 {
     $params = [];
     try {
         $params = Cache::rememberForever('global_params', function () {
             if (!Schema::hasTable('settings')) {
                 return collect();
             }
             return Setting::get();
         });
         $params = $params->groupBy('site_id')->toArray();
     } catch (\Exception $e) {
     }
     $siteId = site()->id;
     $params = isset($params[$siteId]) ? collect($params[$siteId])->pluck('value', 'key') : [];
     if ($key == null) {
         return $params;
     }
     return isset($params[$key]) ? $params[$key] : $default;
 }
开发者ID:livecms,项目名称:core,代码行数:20,代码来源:helpers.php

示例15: createInstance

 protected static function createInstance()
 {
     if (config('app.debug') && !config('trans.cache_on_debug')) {
         \Cache::forget('po_cache');
     }
     return \Cache::rememberForever('po_cache', function () {
         $basePath = config('trans.translations_path');
         $locales = config('trans.supported_locales');
         $translator = new SymfonyTranslator(config('app.locale'));
         $translator->addLoader('po', new PoFileLoader());
         $translator->setFallbackLocales([config('app.locale')]);
         foreach ($locales as $locale) {
             $path = base_path($basePath . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES');
             $file = $path . DIRECTORY_SEPARATOR . 'messages.po';
             if (file_exists($file)) {
                 $translator->addResource('po', $file, $locale);
                 $translator->getCatalogue($locale);
             }
         }
         return $translator;
     });
 }
开发者ID:gummibeer,项目名称:laravel-translation,代码行数:22,代码来源:Translator.php


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