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


PHP Repository::increment方法代碼示例

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


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

示例1: handle

 /**
  * Source: http://fideloper.com/laravel-http-middleware.
  */
 public function handle($request, Closure $next)
 {
     $limit = $this->config->get('api.ratelimit.requests');
     $time = $this->config->get('api.ratelimit.time');
     // Rate limit by IP address
     $key = sprintf('api:%s', $request->get('key'));
     // Add if doesn't exist
     $this->cache->add($key, 0, $time);
     // Add to count
     $count = $this->cache->increment($key);
     if ($count > $limit) {
         throw new TooManyRequestsHttpException($time * 60, 'Rate limit exceed.');
     }
     return $next($request);
 }
開發者ID:MehmetNuri,項目名稱:screeenly,代碼行數:18,代碼來源:ApiThrottle.php

示例2: 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

示例3: hit

 /**
  * Increment the counter for a given key for a given decay time.
  *
  * @param  string  $key
  * @param  int  $decayMinutes
  * @return int
  */
 public function hit($key, $decayMinutes = 1)
 {
     $this->cache->add($key, 1, $decayMinutes);
     return (int) $this->cache->increment($key);
 }
開發者ID:jooorooo,項目名稱:cache,代碼行數:12,代碼來源:RateLimiter.php

示例4: incrementAttempts

 /**
  * Increment the number of failed attempts.
  *
  * @author	Andrea Marco Sartori
  * @return	void
  */
 public function incrementAttempts()
 {
     $this->cache->add($this->key, 0, $this->getExpiry());
     $this->cache->increment($this->key);
 }
開發者ID:ChristianGiupponi,項目名稱:Auth,代碼行數:11,代碼來源:CachingThrottler.php


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