redis_rate_limiter 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +5 -5
  2. data/lib/redis_rate_limiter.rb +4 -4
  3. metadata +5 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0c1c894115b2d5af24dca35db72e9450dd8c2741
4
- data.tar.gz: f405599f4d9065184459f535db2a56cbaed70a06
2
+ SHA256:
3
+ metadata.gz: 131cc6a6a6693dd690435dc804387a1f3bd82f28e7d3ff75b0ebe8d3ca23645f
4
+ data.tar.gz: d996d586a2676b65dc68eaefde091f217d697715629f13ef8a5abcf486490978
5
5
  SHA512:
6
- metadata.gz: 41449db5a1714e0df024692339d8c54d7e07e6164ff55b56c7778d0bcbc54723ebca702e211f7421058735573be71f14f860d251ed77e5406e7a7006d973b948
7
- data.tar.gz: d61b84e9cf0bab162e3b9185e4fb6d3e2c84b51a0898dc29951ba4219b43e8d80748e6bfc6ea06529fef9fc2f35c6b525e9c745ca3249d53aa0b4903177ed087
6
+ metadata.gz: a8744a7a0947b3a242d7a220fcb0f6b06cb0202699b8bea34727f9e8ab65f00abbe7b7caf3c6b46454c773e22d2d3586cbc553dd1bf1f365d86fc16b4e0d25ec
7
+ data.tar.gz: 0a8d6010cd67df6215d89e0d98f6b6f8264b1baba4c171528ceadeba955dfe9e043c05029e201585b38f75a06c74951272485b0528f0e3ea18b87888c8aad1e7
@@ -32,10 +32,10 @@ class RedisRateLimiter
32
32
  # @param [time] time UNIX timestamp of event
33
33
  def add subject, time = Time.now.to_f
34
34
  subject_key = "#{@key}:#{subject}"
35
- @redis.multi do
36
- @redis.lpush(subject_key, time)
37
- @redis.ltrim(subject_key, 0, @limit - 1)
38
- @redis.expire(subject_key, @interval)
35
+ @redis.multi do |pipeline|
36
+ pipeline.lpush(subject_key, time)
37
+ pipeline.ltrim(subject_key, 0, @limit - 1)
38
+ pipeline.expire(subject_key, @interval)
39
39
  end
40
40
  end
41
41
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_rate_limiter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Xie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-10 00:00:00.000000000 Z
11
+ date: 2023-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 4.6.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 4.6.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -148,8 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  - !ruby/object:Gem::Version
149
149
  version: '0'
150
150
  requirements: []
151
- rubyforge_project:
152
- rubygems_version: 2.3.0
151
+ rubygems_version: 3.0.3.1
153
152
  signing_key:
154
153
  specification_version: 4
155
154
  summary: Redis-backed rate limiter