redis_rate_limiter 0.0.6 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/redis_rate_limiter.rb +2 -2
- metadata +36 -36
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a9a12dbb2c0de8e121e8b7b3c7294ce9d06338f2
|
4
|
+
data.tar.gz: b080e7d39a8f4878c3c41db51b537189be98ca02
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6a28ea510a522378b9517ff7790952720d9e4865711772a94042088ca9a103fa595d4a312ae8e6ae7313e92e4227591c19c52cb6a9a96910183791de7b2de61d
|
7
|
+
data.tar.gz: 0005d0bcca887f45d68ac14f8942c4e90e5b6bf8d35a0e0bfdf01e46c31fc7dd6ff86161ad3c83c37c2d5981c03a5fe1661f7b1d14bfb5ca1ab2aec515dead38
|
data/lib/redis_rate_limiter.rb
CHANGED
@@ -30,7 +30,7 @@ class RedisRateLimiter
|
|
30
30
|
#
|
31
31
|
# @param [String] subject A name to uniquely identify subject
|
32
32
|
# @param [time] time UNIX timestamp of event
|
33
|
-
def add subject, time = Time.now.
|
33
|
+
def add subject, time = Time.now.to_f
|
34
34
|
subject = "#{@key}:#{subject}"
|
35
35
|
@redis.multi do
|
36
36
|
@redis.lpush(subject, time)
|
@@ -47,6 +47,6 @@ class RedisRateLimiter
|
|
47
47
|
subject = "#{@key}:#{subject}"
|
48
48
|
return false if @redis.llen(subject) < @limit
|
49
49
|
last = @redis.lindex(subject, -1)
|
50
|
-
Time.now.
|
50
|
+
Time.now.to_f - last.to_f < @interval
|
51
51
|
end
|
52
52
|
end
|
metadata
CHANGED
@@ -1,114 +1,115 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_rate_limiter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.8
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Sean Xie
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-12-30 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: redis
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
47
|
+
version: 3.1.0
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
54
|
+
version: 3.1.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-its
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
62
69
|
- !ruby/object:Gem::Dependency
|
63
70
|
name: mock_redis
|
64
71
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
72
|
requirements:
|
67
|
-
- -
|
73
|
+
- - ">="
|
68
74
|
- !ruby/object:Gem::Version
|
69
75
|
version: '0'
|
70
76
|
type: :development
|
71
77
|
prerelease: false
|
72
78
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
79
|
requirements:
|
75
|
-
- -
|
80
|
+
- - ">="
|
76
81
|
- !ruby/object:Gem::Version
|
77
82
|
version: '0'
|
78
83
|
- !ruby/object:Gem::Dependency
|
79
84
|
name: coveralls
|
80
85
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
86
|
requirements:
|
83
|
-
- -
|
87
|
+
- - ">="
|
84
88
|
- !ruby/object:Gem::Version
|
85
89
|
version: '0'
|
86
90
|
type: :development
|
87
91
|
prerelease: false
|
88
92
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
93
|
requirements:
|
91
|
-
- -
|
94
|
+
- - ">="
|
92
95
|
- !ruby/object:Gem::Version
|
93
96
|
version: '0'
|
94
97
|
- !ruby/object:Gem::Dependency
|
95
98
|
name: yard
|
96
99
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
100
|
requirements:
|
99
|
-
- -
|
101
|
+
- - ">="
|
100
102
|
- !ruby/object:Gem::Version
|
101
103
|
version: '0'
|
102
104
|
type: :development
|
103
105
|
prerelease: false
|
104
106
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
107
|
requirements:
|
107
|
-
- -
|
108
|
+
- - ">="
|
108
109
|
- !ruby/object:Gem::Version
|
109
110
|
version: '0'
|
110
111
|
description: Redis-backed rate limiter
|
111
|
-
email:
|
112
|
+
email: sean@tellapart.com
|
112
113
|
executables: []
|
113
114
|
extensions: []
|
114
115
|
extra_rdoc_files: []
|
@@ -117,27 +118,26 @@ files:
|
|
117
118
|
homepage: https://rubygems.org/gems/redis_rate_limiter
|
118
119
|
licenses:
|
119
120
|
- MIT
|
121
|
+
metadata: {}
|
120
122
|
post_install_message:
|
121
123
|
rdoc_options: []
|
122
124
|
require_paths:
|
123
125
|
- lib
|
124
126
|
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
-
none: false
|
126
127
|
requirements:
|
127
|
-
- -
|
128
|
+
- - ">="
|
128
129
|
- !ruby/object:Gem::Version
|
129
130
|
version: '0'
|
130
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
-
none: false
|
132
132
|
requirements:
|
133
|
-
- -
|
133
|
+
- - ">="
|
134
134
|
- !ruby/object:Gem::Version
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
|
-
rubygems_version:
|
138
|
+
rubygems_version: 2.2.2
|
139
139
|
signing_key:
|
140
|
-
specification_version:
|
140
|
+
specification_version: 4
|
141
141
|
summary: Redis-backed rate limiter
|
142
142
|
test_files: []
|
143
143
|
has_rdoc:
|