redis_rate_limiter 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redis_rate_limiter.rb +8 -0
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c1c894115b2d5af24dca35db72e9450dd8c2741
|
4
|
+
data.tar.gz: f405599f4d9065184459f535db2a56cbaed70a06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41449db5a1714e0df024692339d8c54d7e07e6164ff55b56c7778d0bcbc54723ebca702e211f7421058735573be71f14f860d251ed77e5406e7a7006d973b948
|
7
|
+
data.tar.gz: d61b84e9cf0bab162e3b9185e4fb6d3e2c84b51a0898dc29951ba4219b43e8d80748e6bfc6ea06529fef9fc2f35c6b525e9c745ca3249d53aa0b4903177ed087
|
data/lib/redis_rate_limiter.rb
CHANGED
@@ -60,6 +60,14 @@ class RedisRateLimiter
|
|
60
60
|
elapsed > @interval ? 0.0 : @interval - elapsed
|
61
61
|
end
|
62
62
|
|
63
|
+
# Get number of events currently recorded for subject
|
64
|
+
#
|
65
|
+
# @param [String] subject Name which uniquely identifies subject
|
66
|
+
# @return [Integer] Returns number of events currently recorded for subject
|
67
|
+
def count subject
|
68
|
+
@redis.llen("#{@key}:#{subject}")
|
69
|
+
end
|
70
|
+
|
63
71
|
private
|
64
72
|
|
65
73
|
def time_since_oldest subject_key
|
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.0
|
4
|
+
version: 0.1.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:
|
11
|
+
date: 2017-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: timecop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description: Redis-backed rate limiter
|
112
126
|
email: sean@tellapart.com
|
113
127
|
executables: []
|
@@ -135,9 +149,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
149
|
version: '0'
|
136
150
|
requirements: []
|
137
151
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.
|
152
|
+
rubygems_version: 2.3.0
|
139
153
|
signing_key:
|
140
154
|
specification_version: 4
|
141
155
|
summary: Redis-backed rate limiter
|
142
156
|
test_files: []
|
143
|
-
has_rdoc:
|