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


PHP Cache::forever方法代码示例

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


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

示例1: generate

 public function generate($args)
 {
     if (count($args) != 1) {
         die(self::$usageMessage);
     }
     $model = $args[0];
     $table = Str::plural(Str::lower($model));
     $options = array('Model' => $model, 'Table' => $table, 'DefaultField' => 'text', 'ParentID' => 'parent_id', 'Leaf' => 'leaf');
     $r = new ReflectionClass($model);
     preg_match_all('#@(.*?)\\n#s', $r->getDocComment(), $annotations);
     if (!empty($annotations)) {
         foreach ($annotations[0] as $annotation) {
             preg_match('#@(?P<name>\\w+)[ ]*(\\([ ]*(?P<value>\\w+)[ ]*\\))?\\n#s', $annotation, $a);
             if (array_key_exists($a['name'], $options)) {
                 $options[$a['name']] = $a['value'];
             }
         }
     }
     $columns = DB::query('SHOW columns from ' . $table);
     if (Cache::has('ext' . $model, $columns)) {
         $was_cached = true;
     } else {
         Cache::forever('ext' . $model, $columns);
         $was_cached = false;
     }
     // Generate code
     $this->generateExtModel($columns, $model, $options);
     $this->generateGrid($columns, $model, $options, $was_cached);
     $this->generateForm($columns, $model, $options, $was_cached);
     $this->generateTree($model, $options, $was_cached);
     /**************************************************************/
     echo 'Task executed successfully';
 }
开发者ID:SerdarSanri,项目名称:LextJS,代码行数:33,代码来源:ext.php

示例2: render

 public function render()
 {
     $key = md5($this->getPath());
     $lastModified = $this->files->lastModified($this->getPath());
     $generate = false;
     if ($lastModifiedCache = \Cache::get("{$key}.lastmodified", false) !== false && \Cache::has($key)) {
         if ($lastModified !== $lastModified) {
             $generate = true;
         }
     } else {
         $generate = true;
     }
     if (config('app.debug')) {
         $generate = true;
     }
     $rendered = '';
     if ($generate === true) {
         $rendered = $this->parser->parse($this->files->get($this->getPath()));
         \Cache::forever($key, $rendered);
         \Cache::forever("{$key}.lastmodified", $lastModified);
     } else {
         $rendered = \Cache::get($key, false);
     }
     return $rendered;
 }
开发者ID:docit,项目名称:phpdoc-hook,代码行数:25,代码来源:PhpdocDocument.php

示例3: get

 /**
  * Fetch setting
  *
  * @param $key
  * @return null
  */
 public function get($key)
 {
     /**
      * Setup cache key
      */
     $cacheKey = 'setting_' . md5($key);
     /**
      * Check if in cache
      */
     if (\Cache::has($cacheKey)) {
         return \Cache::get($cacheKey);
     }
     /**
      * Fetch from database
      */
     $setting = Setting::where('key', '=', $key)->first();
     /**
      * If a row was found, return the value
      */
     if (is_object($setting) && $setting->getId()) {
         /**
          * Store in cache
          */
         \Cache::forever($cacheKey, $setting->getValue());
         /**
          * Return the data
          */
         return $setting->getValue();
     }
     return null;
 }
开发者ID:codepeak,项目名称:dsettings,代码行数:37,代码来源:DSetting.php

示例4: testConfigReadsValuesFromCache

 public function testConfigReadsValuesFromCache()
 {
     Cache::forever('config:all', 'foo');
     $config = App::make('App\\Models\\Config');
     $value = $config->all();
     $this->assertSame('foo', $value);
 }
开发者ID:thomaswelton,项目名称:laravel,代码行数:7,代码来源:CacheModelTest.php

示例5: _setModuleList

 private function _setModuleList()
 {
     if (\Cache::has('modules.backend.list')) {
         $this->_moduleList = \Cache::get('modules.backend.list');
         return;
     }
     $moduleDir = app_path() . '/../modules/';
     $result = array();
     if ($handle = opendir($moduleDir)) {
         while (false !== ($dir = readdir($handle))) {
             if ($dir != '.' && $dir != '..') {
                 if (is_dir($moduleDir . $dir)) {
                     $backendData = false;
                     if (file_exists($moduleDir . $dir . '/backend.json')) {
                         $backendData = json_decode(file_get_contents($moduleDir . $dir . '/backend.json'));
                     }
                     $result[] = ['name' => $dir, "dir" => $moduleDir . $dir, 'backend' => $backendData];
                 }
             }
         }
         closedir($handle);
     }
     $this->_moduleList = $result;
     \Cache::forever('modules.backend.list', $result);
 }
开发者ID:ksp-media,项目名称:laikacms,代码行数:25,代码来源:ModuleService.php

示例6: run

 /**
  * Runs all jobs that do not have a cool down.
  * Returns false or the number of executed jobs.
  * 
  * @return boolean|int
  */
 public function run()
 {
     $now = time();
     if ($this->cache->has($this->cacheKey)) {
         $executed = $this->cache->get($this->cacheKey);
         if ($now - $executed < $this->coolDown * 60) {
             return false;
         }
     }
     $this->cache->forever($this->cacheKey, $now);
     $counter = 0;
     foreach ($this->jobs as $name => $jobBag) {
         $job = $this->getOrMake($name);
         $key = $this->makeCacheKey($name);
         $executed = null;
         if ($this->cache->has($key)) {
             $executed = $this->cache->get($key);
             if ($now - $executed < $job->getInterval() * 60) {
                 continue;
             }
         }
         if ($job->getActive()) {
             $now = time();
             $job->run($executed);
             $this->cache->forever($key, $now);
             $counter++;
         }
     }
     return $counter;
 }
开发者ID:chriskonnertz,项目名称:jobs,代码行数:36,代码来源:Jobs.php

示例7: setCache

 /**
  * 设置缓存
  * @param string $cachename
  * @param mixed $value
  * @param int $expired
  * @return boolean
  */
 public static function setCache($cachename, $value, $expired = null)
 {
     $data = array('value' => $value);
     if ($expired) {
         $data['expires_at'] = time() + $expired;
     }
     \Cache::forever($cachename, json_encode($data));
 }
开发者ID:formatcc,项目名称:laravel-wechat,代码行数:15,代码来源:Cache.php

示例8: update

 public function update(Request $request)
 {
     $this->authorize('authorizeAccess', 'contactus');
     $this->contactus->update($request->except('_token'));
     $contactInfo = $this->contactus->first();
     \Cache::forget('contactusInfo');
     \Cache::forever('contactusInfo', $contactInfo);
     return redirect()->back()->with('success', 'Contact Us Information has been updated');
 }
开发者ID:uusa35,项目名称:ebook,代码行数:9,代码来源:ContactUsController.php

示例9: getDefaultCityList

 private function getDefaultCityList($country_code, $province_code)
 {
     $cityCodes = \Cache::get('bgcountry_city_' . $country_code . '_' . $province_code);
     if (!$cityCodes) {
         $cityCodes = $this->db->table('bgcity')->where(strlen($country_code) == 2 ? 'cty_code_2' : 'cty_code_3', '=', $country_code)->where(strlen($province_code) < 4 ? 'prov_short_code' : 'prov_long_code', '=', $province_code)->orderBy('city_name')->lists('city_name', $this->city_value_field);
         \Cache::forever('bgcountry_city_' . $country_code . '_' . $province_code, $cityCodes);
     }
     return $cityCodes;
 }
开发者ID:bgies,项目名称:bgcountry,代码行数:9,代码来源:BgCountryController.php

示例10: get

 public static function get($arrArg = [])
 {
     if (Cache::has('categories')) {
         $cache = Cache::get('categories');
     } else {
         $cache = self::getRecursive($arrArg);
         Cache::forever('categories', $cache);
     }
     return $cache;
 }
开发者ID:nguyendaivu,项目名称:imagestock,代码行数:10,代码来源:ProductCategory.php

示例11: setCache

 /**
  * Cache the data.
  *
  * @param string $index
  * @param array $data
  * @param bool|int $period Hours
  *
  * @return bool
  */
 public function setCache($index, $data, $period = false)
 {
     if (!$this->getCache($index)) {
         $data = serialize($data);
         if (!$period) {
             \Cache::forever($index, $data);
         }
     }
     return false;
 }
开发者ID:maxyc,项目名称:geolara,代码行数:19,代码来源:CacheTrait.php

示例12: getList

 public function getList()
 {
     if (\Cache::has('widgets-list')) {
         return \Cache::get('widgets-list');
     } else {
         $lists = $this->model->where('status', 1)->get();
         \Cache::forever($lists, 'widgets-list');
         return $lists;
     }
 }
开发者ID:weddingjuma,项目名称:world,代码行数:10,代码来源:CustomWidgetRepository.php

示例13: __construct

 /**
  * Create a new URL Generator instance.
  *
  * @param  \Illuminate\Routing\RouteCollection $routes
  * @param  \Illuminate\Http\Request $request
  * @return void
  */
 public function __construct(RouteCollection $routes, Request $request)
 {
     parent::__construct($routes, $request);
     if (\Cache::has('assets-cdn::commitID')) {
         $this->commitID = \Cache::get('assets-cdn::commitID');
     } else {
         $this->commitID = exec('git rev-parse HEAD');
         \Cache::forever('assets-cdn::commitID', $this->commitID);
     }
     $this->cdnURL = config('assets-cdn.cdn-url');
 }
开发者ID:mezatech,项目名称:assets-cdn,代码行数:18,代码来源:UrlGenerator.php

示例14: page

 public function page($page_index)
 {
     $isSuperAdmin = Auth::user()->isSuperAdmin();
     $cacheKey = sprintf('wall.%d.%d', (bool) $isSuperAdmin, (int) $page_index);
     $wallContent = Cache::get($cacheKey);
     if (empty($wallContent)) {
         $wallContent = View::make('partials.wall.page', array('isSuperAdmin' => $isSuperAdmin, 'page_index' => $page_index))->render();
         Cache::forever($cacheKey, $wallContent);
     }
     return $wallContent;
 }
开发者ID:urashima82,项目名称:intranet,代码行数:11,代码来源:WallPostController.php

示例15: initShopConfig

 protected function initShopConfig()
 {
     if (!Cache::get('shop_config')) {
         $shop_config = new Shop_config();
         $shop_config_arr = $shop_config->all()->toArray();
         foreach ($shop_config_arr as $key => $value) {
             $shop_configs[$value['model']][$value['name']] = $value['value'];
         }
         Cache::forever('shop_config', $shop_configs);
     }
 }
开发者ID:leebivip,项目名称:laravel_cmp,代码行数:11,代码来源:CacheEventHandler.php


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