當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。