当前位置: 首页>>代码示例>>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;未经允许,请勿转载。