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