當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Cache::get方法代碼示例

本文整理匯總了PHP中Illuminate\Support\Facades\Cache::get方法的典型用法代碼示例。如果您正苦於以下問題:PHP Cache::get方法的具體用法?PHP Cache::get怎麽用?PHP Cache::get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Support\Facades\Cache的用法示例。


在下文中一共展示了Cache::get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get

 /**
  * @param Query $query
  * @return Result|null
  */
 private function get($query)
 {
     if (!$this->cache) {
         return null;
     } elseif (!($serialized = $this->cache->get($query->getHashKey()))) {
         return null;
     }
     return unserialize($serialized);
 }
開發者ID:meshkorea,項目名稱:laravel-postcodify,代碼行數:13,代碼來源:Service.php

示例2: handle

 /**
  * @inheritdoc
  */
 public function handle($arguments)
 {
     if (!Cache::has('site-' . $arguments)) {
         $this->replyWithMessage("Não foi encontrado nenhum site com esse argumento.");
         return;
     }
     $site = Cache::get('site-' . $arguments);
     // Validate if the URL isn't on the database yet
     if (Site::where('url', '=', $site)->first() != null) {
         $this->replyWithMessage("O site {$site} já se encontra na base de dados.");
         return;
     }
     $site_obj = new Site();
     $site_obj->url = $site;
     $site_obj->save();
     $this->replyWithMessage($site . " foi adicionado à base de dados.", true);
     // Notify the sitesbloqueados.pt about the new site
     $url = 'https://sitesbloqueados.pt/wp-json/ahoy/refresh';
     $cmd = "curl -X GET -H 'Content-Type: application/json'";
     $cmd .= " " . "'" . $url . "'";
     $cmd .= " > /dev/null 2>&1 &";
     exec($cmd, $output);
     // Flush the PAC cache
     Cache::tags(['generate_pac'])->flush();
     // Remove the cache
     Cache::forget('site-' . $arguments);
     Cache::forget('site-list');
 }
開發者ID:revolucaodosbytes,項目名稱:ahoy-api,代碼行數:31,代碼來源:AddNewSiteCommand.php

示例3: handle

 /**
  * @throws \Exception
  */
 public function handle()
 {
     $name = $this->argument('name');
     $isUserRestrict = $this->confirm('User restricted ?', false);
     $author = $this->ask("Your username", Cache::get('developer.username', ''));
     Cache::forever('developer.username', $author);
     $generator = new Generator($name, $isUserRestrict, $author);
     $templateData = $generator->getTemplateData();
     $files = $generator->getFiles();
     $belongToRelations = $this->getRelation('BelongTo');
     if ($isUserRestrict) {
         $belongToRelations[] = 'user';
     }
     $belongToRelations = array_unique($belongToRelations);
     $manyToManyRelations = $this->getRelation('ManyToMany');
     $manyToManyRelations = array_unique($manyToManyRelations);
     $fields = $this->getFields();
     $this->summary($templateData, $isUserRestrict);
     $this->fieldsSummary($fields);
     $this->generate($generator, $fields, ['belongTo' => $belongToRelations, 'manyToMany' => $manyToManyRelations]);
     $this->runComposerDumpAutoload();
     $this->migrateDatabase();
     $this->generateDocumentation();
     $this->info("");
     $this->info("What you need to do now ?");
     $this->info("\t [] Add Acl/Scope to your route in routes.php");
     $this->info("\t [] Fill data provider for " . $files['controllerTest']);
     $this->info("\t [] Fill data provider for " . $files['repositoryTest']);
 }
開發者ID:ndrx-io,項目名稱:elude,代碼行數:32,代碼來源:ApiGenerator.php

示例4: _fetchDataset

 private function _fetchDataset($filter)
 {
     return Cache::get($this->key, function () use($filter) {
         Cache::add($this->key, $data = $this->_getDataPartialRecursive($filter), 60);
         return $data;
     });
 }
開發者ID:skizu,項目名稱:freshdeskreporting,代碼行數:7,代碼來源:DataController.php

示例5: tableToArray

 /**
  * Return a simple list of entries in the table.
  *
  * May cache the results for up to 60 minutes.
  *
  * @return	array of Fluent objects
  */
 public static function tableToArray()
 {
     $me = new static();
     $cache_key = $me->cacheKey();
     // Return the array from the cache if it is present.
     if (Cache::has($cache_key)) {
         return (array) Cache::get($cache_key);
     }
     // Otherwise put the results into the cache and return them.
     $results = [];
     $query = static::all();
     // If the current model uses softDeletes then fix the
     // query to exclude those objects.
     foreach (class_uses(__CLASS__) as $traitName) {
         if ($traitName == 'SoftDeletes') {
             $query = static::whereNull('deleted_at')->get();
             break;
         }
     }
     /** @var Cacheable $row */
     foreach ($query as $row) {
         $results[$row->getIndexKey()] = $row->toFluent();
     }
     Cache::put($cache_key, $results, 60);
     return $results;
 }
開發者ID:delatbabel,項目名稱:keylists,代碼行數:33,代碼來源:Cacheable.php

示例6: get

 /**
  * Returns cached data
  *
  * @param  string  $key
  * @return mixed
  */
 public static function get($key)
 {
     if (!isset(static::$cache[$key])) {
         static::$cache[$key] = parent::get($key);
     }
     return static::$cache[$key];
 }
開發者ID:carriercomm,項目名稱:sticky-notes,代碼行數:13,代碼來源:Cache.php

示例7: getCachedAssemblyItems

 /**
  * Returns the current cached items assembly if
  * it exists inside the cache. Returns false
  * otherwise.
  *
  * @return bool|\Illuminate\Database\Eloquent\Collection
  */
 public function getCachedAssemblyItems()
 {
     if ($this->hasCachedAssemblyItems()) {
         return Cache::get($this->getAssemblyCacheKey());
     }
     return false;
 }
開發者ID:Anshdesire,項目名稱:inventory,代碼行數:14,代碼來源:AssemblyTrait.php

示例8: check

 /**
  * Check the token
  *
  * @param   string  $token
  * @return  boolean
  */
 public function check($token)
 {
     if (!Cache::has($this->getCacheKey())) {
         return false;
     }
     return Cache::get($this->getCacheKey()) === $token;
 }
開發者ID:malahierba-lab,項目名稱:token,代碼行數:13,代碼來源:Token.php

示例9: isAdmin

 public function isAdmin()
 {
     if (Cache::has('role.' . Auth::id()) && Cache::get('role.' . Auth::id()) === 'admin') {
         return true;
     }
     return false;
 }
開發者ID:uusa35,項目名稱:turnkw,代碼行數:7,代碼來源:UserTrait.php

示例10: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Cache::get('role.' . Auth::id()) == 'admin') {
         return $next($request);
     }
     abort(404);
 }
開發者ID:uusa35,項目名稱:turnkw,代碼行數:14,代碼來源:AdminZone.php

示例11: compose

 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     if (!Cache::get('popular_categories')) {
         Cache::put('popular_categories', $this->categories->getPopular(), 60);
     }
     $view->with('popular_categories', Cache::get('popular_categories'));
 }
開發者ID:ambarsetyawan,項目名稱:brewski,代碼行數:13,代碼來源:PopularCategoriesComposer.php

示例12: fetch

 public function fetch(Route $route, Request $request)
 {
     $key = self::makeCacheKey($request->url());
     if (Cache::has($key)) {
         return Cache::get($key);
     }
 }
開發者ID:RichJones22,項目名稱:TimeTrax,代碼行數:7,代碼來源:CacheFilters.php

示例13: compose

 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     if (!Cache::get('recent_posts')) {
         Cache::put('recent_posts', $this->posts->getAll('published', null, 'published_at', 'desc', 5), 10);
     }
     $view->with('recent_posts', Cache::get('recent_posts'));
 }
開發者ID:ambarsetyawan,項目名稱:brewski,代碼行數:13,代碼來源:RecentPostsComposer.php

示例14: getTimestampMigrationName

 /**
  * @return string
  */
 protected function getTimestampMigrationName()
 {
     if (!Cache::has(static::CACHENAME)) {
         Cache::forever(static::CACHENAME, date('Y_m_d_His') . '_' . $this->getMigrationName());
     }
     return Cache::get(static::CACHENAME);
 }
開發者ID:jayaregalinada,項目名稱:common,代碼行數:10,代碼來源:OptionServiceProvider.php

示例15: currentWebsiteData

 /**
  * Determine the current website data.
  *
  * Returns null if the web site is not found in the websites table.
  *
  * @return	array
  */
 public static function currentWebsiteData()
 {
     static $current_data;
     $BASE_URL = static::currentServerName();
     $cache_key = 'website-data.' . $BASE_URL;
     // Get the current ID from the cache if it is present.
     if (empty($current_data)) {
         if (Cache::has($cache_key)) {
             return Cache::get($cache_key);
         }
     }
     // If the cache doesn't have it then get it from the database.
     if (empty($current_data)) {
         // Have to do this using a raw query because Laravel doesn't INSTR.
         try {
             /** @var Website $result */
             $result = static::whereRaw("INSTR('" . $BASE_URL . "', `http_host`) > 0")->orderBy(DB::raw('LENGTH(`http_host`)'), 'desc')->first();
             if (empty($result)) {
                 $current_data = null;
             } else {
                 $current_data = $result->toArray();
             }
             Cache::put($cache_key, $current_data, 60);
         } catch (\Exception $e) {
             $current_data = null;
         }
     }
     return $current_data;
 }
開發者ID:delatbabel,項目名稱:site-config,代碼行數:36,代碼來源:Website.php


注:本文中的Illuminate\Support\Facades\Cache::get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。