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


PHP Repository::has方法代码示例

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


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

示例1: stats

 public function stats(Cache $cache)
 {
     if (!$cache->has('tickets.total') && !$cache->has('tickets.open')) {
         return $this->responseNoteFound('No stats found');
     }
     return $this->respond(['tickets' => ['open' => $cache->get('tickets.open'), 'total' => $cache->get('tickets.total')]]);
 }
开发者ID:anouarabdsslm,项目名称:micro-service,代码行数:7,代码来源:TicketController.php

示例2: authenticate

 /**
  * @return string Access token
  */
 public function authenticate()
 {
     if (!$this->repository->has('brightcove.bearer')) {
         $this->repository->put('brightcove.bearer', $this->brightcove->authenticate(), $this->duration);
     }
     return $this->repository->get('brightcove.bearer');
 }
开发者ID:ronaldcastillo,项目名称:brightcove,代码行数:10,代码来源:BrightCoveCacheDecorator.php

示例3: check

 public function check($value)
 {
     $result = false;
     if ($this->store->has('captcha')) {
         $captchaStore = $this->store->get('captcha');
         $result = $captchaStore->check($value);
         $this->store->forever('captcha', $captchaStore);
     }
     return $result;
 }
开发者ID:disik69,项目名称:backend.english-roulette-v0.3,代码行数:10,代码来源:Captcha.php

示例4: all

 /**
  * Get the dataset collection
  *
  * @return \Illuminate\Support\Collection
  */
 public function all()
 {
     $cacheKey = 'dataset' . (new ReflectionClass($this))->getShortName();
     if ($this->cache->has($cacheKey)) {
         return $this->cache->get($cacheKey);
     }
     $dataset = $this->cache->rememberForever($cacheKey, function () {
         return $this->getDataset();
     });
     return $dataset;
 }
开发者ID:TFidryForks,项目名称:spira,代码行数:16,代码来源:Dataset.php

示例5: tooManyAttempts

 /**
  * Determine if the given key has been "accessed" too many times.
  *
  * @param  string  $key
  * @param  int  $maxAttempts
  * @param  int  $decayMinutes
  * @return bool
  */
 public function tooManyAttempts($key, $maxAttempts, $decayMinutes = 1)
 {
     $lockedOut = $this->cache->has($key . ':lockout');
     if ($this->attempts($key) > $maxAttempts || $lockedOut) {
         if (!$lockedOut) {
             $this->cache->add($key . ':lockout', time() + $decayMinutes * 60, $decayMinutes);
         }
         return true;
     }
     return false;
 }
开发者ID:jooorooo,项目名称:cache,代码行数:19,代码来源:RateLimiter.php

示例6: tooManyAttempts

 /**
  * Determine if the given key has been "accessed" too many times.
  *
  * @param  string  $key
  * @param  int  $maxAttempts
  * @param  float|int  $decayMinutes
  * @return bool
  */
 public function tooManyAttempts($key, $maxAttempts, $decayMinutes = 1)
 {
     if ($this->cache->has($key . ':lockout')) {
         return true;
     }
     if ($this->attempts($key) > $maxAttempts) {
         $this->cache->add($key . ':lockout', time() + $decayMinutes * 60, $decayMinutes);
         $this->resetAttempts($key);
         return true;
     }
     return false;
 }
开发者ID:davidhemphill,项目名称:framework,代码行数:20,代码来源:RateLimiter.php

示例7: performRealTimeQuery

 /**
  * Query the Google Analytics Real Time Reporting Service with given parameters.
  *
  * @param int    $id
  * @param string $metrics
  * @param array  $others
  *
  * @return mixed
  */
 public function performRealTimeQuery($id, $metrics, array $others = [])
 {
     $realTimeCacheName = $this->determineRealTimeCacheName(func_get_args());
     if ($this->useRealTimeCache() && $this->cache->has($realTimeCacheName)) {
         return $this->cache->get($realTimeCacheName);
     }
     $googleAnswer = $this->service->data_realtime->get($id, $metrics, $others);
     if ($this->useRealTimeCache()) {
         $this->cache->put($realTimeCacheName, $googleAnswer, Carbon::now()->addSeconds($this->realTimeCacheLifeTimeInSeconds));
     }
     return $googleAnswer;
 }
开发者ID:rtcustom,项目名称:laravel-analytics,代码行数:21,代码来源:GoogleApiHelper.php

示例8: hasItem

 /**
  * {@inheritdoc}
  */
 public function hasItem($key)
 {
     $this->validateKey($key);
     if (isset($this->deferred[$key])) {
         $item = $this->deferred[$key];
         $expiresAt = $this->getExpiresAt($item);
         if (!$expiresAt) {
             return true;
         }
         return $expiresAt > new DateTimeImmutable();
     }
     return $this->repository->has($key);
 }
开发者ID:madewithlove,项目名称:illuminate-psr-cache-bridge,代码行数:16,代码来源:CacheItemPool.php

示例9: retrieveById

 /**
  * @param mixed $identifier
  * @return \Illuminate\Contracts\Auth\Authenticatable|null
  */
 public function retrieveById($identifier)
 {
     $cacheKey = "user:{$identifier}";
     if ($this->cache->has($cacheKey)) {
         return $this->cache->get($cacheKey);
     }
     $result = $this->createModel()->newQuery()->find($identifier);
     if (is_null($result)) {
         return null;
     }
     $this->cache->add($cacheKey, $result, 120);
     return $result;
 }
开发者ID:nazonohito51,项目名称:laravel-jp-reference-chapter8,代码行数:17,代码来源:UserCacheProvider.php

示例10: withoutOverlapping

 /**
  * Do not allow the event to overlap each other.
  *
  * @return $this
  */
 public function withoutOverlapping()
 {
     $this->withoutOverlapping = true;
     return $this->skip(function () {
         return $this->cache->has($this->mutexName());
     });
 }
开发者ID:rosswilson252,项目名称:framework,代码行数:12,代码来源:Event.php

示例11: addHit

 /**
  * Increment the hit counter for the cache key.
  *
  * @param string $key
  *
  * @return bool
  */
 public function addHit($key)
 {
     if (!$this->cache->has($this->getKey($key))) {
         return $this->cache->add($this->getKey($key), 1, 1);
     }
     return $this->cache->increment($this->getKey($key), 1);
 }
开发者ID:bexarcreative,项目名称:using-rate-limiting-on-method-calls-with-laravel,代码行数:14,代码来源:RateLimiter.php

示例12: getProfileFromWatson

 /**
  * Get Full Insights From Watson API.
  *
  * @throws \FindBrok\WatsonBridge\Exceptions\WatsonBridgeException
  *
  * @return \Illuminate\Support\Collection
  */
 public function getProfileFromWatson()
 {
     //We have the request in cache and cache is on
     if ($this->cacheIsOn() && $this->cache->has($this->getContainer()->getCacheKey())) {
         //Return results from cache
         return $this->cache->get($this->getContainer()->getCacheKey());
     }
     //Cross the bridge
     $response = $this->makeBridge()->post('v2/profile', $this->getContainer()->getContentsForRequest());
     //Decode profile
     $profile = collect(json_decode($response->getBody()->getContents(), true));
     //Cache results if cache is on
     if ($this->cacheIsOn()) {
         $this->cache->put($this->getContainer()->getCacheKey(), $profile, $this->cacheLifetime());
     }
     //Return profile
     return $profile;
 }
开发者ID:findbrok,项目名称:laravel-personality-insights,代码行数:25,代码来源:PersonalityInsights.php

示例13: retrieveById

 /**
  * Authコンポーネントのuser()メソッドなどを利用した場合に実行されるメソッドです
  * デフォルトの場合、user()メソッドコール時に都度SQLが発行されますので、cacheを利用します。
  * ユーザー情報更新時などにcacheを再生成するように実装します。
  *
  * @param  mixed $identifier
  *
  * @return \Illuminate\Contracts\Auth\Authenticatable|null
  */
 public function retrieveById($identifier)
 {
     /**
      * user:$identifier(user_id) としてキャッシュを検索し、
      * 見つからない場合は作成してデータベースから取得したデータを保持します
      * 以降はデータベースへアクセスしません
      */
     $cacheKey = "user:{$identifier}";
     if ($this->cache->has($cacheKey)) {
         return $this->cache->get($cacheKey);
     }
     $result = $this->createModel()->newQuery()->find($identifier);
     if (is_null($result)) {
         return null;
     }
     $this->cache->add($cacheKey, $result, 120);
     return $result;
 }
开发者ID:laravel-jp-reference,项目名称:chapter8,代码行数:27,代码来源:UserCacheProvider.php

示例14: withoutOverlapping

 /**
  * Do not allow the event to overlap each other.
  *
  * @return $this
  *
  * @throws \LogicException
  */
 public function withoutOverlapping()
 {
     if (!isset($this->description)) {
         throw new LogicException("A scheduled event name is required to prevent overlapping. Use the 'name' method before 'withoutOverlapping'.");
     }
     return $this->skip(function () {
         return $this->cache->has($this->mutexName());
     });
 }
开发者ID:bryanashley,项目名称:framework,代码行数:16,代码来源:CallbackEvent.php

示例15: render

 /**
  * Render the document.
  *
  * This will run all document:render hooks and then return the
  * output. Should be called within a view.
  *
  * @return string
  */
 public function render()
 {
     if ($this->rendered) {
         return $this->content;
     }
     // todo implement this. if changes are made that influence the attributes (ex, the project config), the cache should drop.
     // this is a example of how to create a unique hash for it. not sure if it would work out
     //        $attributesChanged = md5(collect(array_dot($this->attributes))->values()->transform(function ($val) {
     //            return md5((string)$val);
     //        })->implode('.'));
     $this->codex->dev->benchmark('document');
     $this->hookPoint('document:render');
     if ($this->shouldCache()) {
         $minutes = $this->getCodex()->config('document.cache.minutes', null);
         if ($minutes === null) {
             $lastModified = (int) $this->cache->rememberForever($this->getCacheKey(':last_modified'), function () {
                 return 0;
             });
         } else {
             $lastModified = (int) $this->cache->remember($this->getCacheKey(':last_modified'), $minutes, function () {
                 return 0;
             });
         }
         if ($this->lastModified !== $lastModified || $this->cache->has($this->getCacheKey()) === false) {
             $this->runProcessors();
             $this->cache->put($this->getCacheKey(':last_modified'), $this->lastModified, $minutes);
             $this->cache->put($this->getCacheKey(':content'), $this->content, $minutes);
         } else {
             $this->content = $this->cache->get($this->getCacheKey(':content'));
         }
     } else {
         $this->runProcessors();
     }
     $this->rendered = true;
     $this->hookPoint('document:rendered');
     $this->codex->dev->addMessage($this->toArray());
     $this->codex->dev->stopBenchmark(true);
     return $this->content;
 }
开发者ID:codexproject,项目名称:core,代码行数:47,代码来源:Document.php


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