redis-store 1.8.2 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -7
- data/Appraisals +6 -2
- data/CHANGELOG.md +30 -0
- data/gemfiles/{redis_3_x.gemfile → redis_4_0_x.gemfile} +1 -1
- data/gemfiles/redis_4_1_x.gemfile +7 -0
- data/lib/redis/store/interface.rb +9 -1
- data/lib/redis/store/namespace.rb +73 -29
- data/lib/redis/store/version.rb +1 -1
- data/redis-store.gemspec +1 -3
- data/test/redis/store/namespace_test.rb +68 -11
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 476790788b3d0462db696bc3773a72c18b3f57f04db394e238bc849b04f6b54a
|
4
|
+
data.tar.gz: 443eca0ff3f6acd16c696aadf4e8cb1c34edf213944d489d66fe6508a5ff2390
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 104215ff505c8dd84b0baac16c99a75e117b33dafbc0f654f6f87acbf0fba1b0a1c34ce3e63530566f65289ca725a98b1e0a640cfc878f33e27fb51857a243df
|
7
|
+
data.tar.gz: 49730d0bc9e9a1295aaa6b410cae27c58838f953a71fb6255c53e27dc4faa670b827effbe2d0f614d4d4dfbe5f91b333465c380db44475c466f261d534e2d91c
|
data/.travis.yml
CHANGED
@@ -9,15 +9,16 @@ before_install:
|
|
9
9
|
> ./cc-test-reporter
|
10
10
|
- chmod +x ./cc-test-reporter
|
11
11
|
rvm:
|
12
|
-
- 2.1
|
13
|
-
- 2.2
|
14
12
|
- 2.3
|
15
13
|
- 2.4
|
16
14
|
- 2.5
|
17
15
|
- 2.6
|
16
|
+
- 2.7
|
18
17
|
- ruby-head
|
19
18
|
- jruby-head
|
20
19
|
gemfile:
|
20
|
+
- gemfiles/redis_4_0_x.gemfile
|
21
|
+
- gemfiles/redis_4_1_x.gemfile
|
21
22
|
- gemfiles/redis_4_x.gemfile
|
22
23
|
before_script: "./cc-test-reporter before-build"
|
23
24
|
after_script:
|
@@ -28,11 +29,6 @@ matrix:
|
|
28
29
|
allow_failures:
|
29
30
|
- rvm: jruby-head
|
30
31
|
- rvm: ruby-head
|
31
|
-
exclude:
|
32
|
-
- rvm: 2.1
|
33
|
-
gemfile: gemfiles/redis_4_x.gemfile
|
34
|
-
- rvm: 2.2
|
35
|
-
gemfile: gemfiles/redis_4_x.gemfile
|
36
32
|
deploy:
|
37
33
|
provider: rubygems
|
38
34
|
api_key:
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,35 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.9.0
|
4
|
+
|
5
|
+
Breaking Changes
|
6
|
+
|
7
|
+
* As a factor of updates for Redis v4.2.x, support for Ruby 2.1 and 2.2
|
8
|
+
has been dropped. These Ruby versions are end-of-life anyway.
|
9
|
+
|
10
|
+
Fixed
|
11
|
+
|
12
|
+
* [Compatibility with Redis client v4.2.x](https://github.com/redis-store/redis-store/pull/333)
|
13
|
+
|
14
|
+
Added
|
15
|
+
|
16
|
+
* [Support for edge Ruby's keyword arguments](https://github.com/redis-store/redis-store/pull/334)
|
17
|
+
|
18
|
+
## 1.8.2
|
19
|
+
|
20
|
+
Breaking Changes
|
21
|
+
|
22
|
+
* None
|
23
|
+
|
24
|
+
Added
|
25
|
+
|
26
|
+
* [Add namespace to zincrby and zscore](https://github.com/redis-store/redis-store/pull/323)
|
27
|
+
* [Add namespace to zadd and zrem](https://github.com/redis-store/redis-store/pull/326)
|
28
|
+
|
29
|
+
Fixed
|
30
|
+
|
31
|
+
* None
|
32
|
+
|
3
33
|
## 1.8.1
|
4
34
|
|
5
35
|
Breaking Changes
|
@@ -5,8 +5,16 @@ class Redis
|
|
5
5
|
super(key)
|
6
6
|
end
|
7
7
|
|
8
|
+
REDIS_SET_OPTIONS = %i(ex px nx xx keepttl).freeze
|
9
|
+
private_constant :REDIS_SET_OPTIONS
|
10
|
+
|
8
11
|
def set(key, value, options = nil)
|
9
|
-
|
12
|
+
if options && REDIS_SET_OPTIONS.any? { |k| options.key?(k) }
|
13
|
+
kwargs = REDIS_SET_OPTIONS.each_with_object({}) { |key, h| h[key] = options[key] if options.key?(key) }
|
14
|
+
super(key, value, **kwargs)
|
15
|
+
else
|
16
|
+
super(key, value)
|
17
|
+
end
|
10
18
|
end
|
11
19
|
|
12
20
|
def setnx(key, value, options = nil)
|
@@ -3,28 +3,32 @@ class Redis
|
|
3
3
|
module Namespace
|
4
4
|
FLUSHDB_BATCH_SIZE = 1000
|
5
5
|
|
6
|
-
def set(key,
|
7
|
-
namespace(key) { |k| super(k,
|
6
|
+
def set(key, *args)
|
7
|
+
namespace(key) { |k| super(k, *args) }
|
8
8
|
end
|
9
9
|
|
10
|
-
def setex(key,
|
11
|
-
namespace(key) { |k| super(k,
|
10
|
+
def setex(key, *args)
|
11
|
+
namespace(key) { |k| super(k, *args) }
|
12
12
|
end
|
13
13
|
|
14
|
-
def setnx(key,
|
15
|
-
namespace(key) { |k| super(k,
|
14
|
+
def setnx(key, *args)
|
15
|
+
namespace(key) { |k| super(k, *args) }
|
16
16
|
end
|
17
17
|
|
18
18
|
def ttl(key, options = nil)
|
19
19
|
namespace(key) { |k| super(k) }
|
20
20
|
end
|
21
21
|
|
22
|
-
def get(key,
|
23
|
-
namespace(key) { |k| super(k,
|
22
|
+
def get(key, *args)
|
23
|
+
namespace(key) { |k| super(k, *args) }
|
24
24
|
end
|
25
25
|
|
26
|
-
def exists(
|
27
|
-
|
26
|
+
def exists(*keys)
|
27
|
+
super(*keys.map { |key| interpolate(key) })
|
28
|
+
end
|
29
|
+
|
30
|
+
def exists?(*keys)
|
31
|
+
super(*keys.map { |key| interpolate(key) })
|
28
32
|
end
|
29
33
|
|
30
34
|
def incrby(key, increment)
|
@@ -39,14 +43,14 @@ class Redis
|
|
39
43
|
namespace(pattern) { |p| super(p).map { |key| strip_namespace(key) } }
|
40
44
|
end
|
41
45
|
|
42
|
-
def scan(cursor,
|
43
|
-
if
|
44
|
-
namespace(
|
45
|
-
cursor, keys = super(cursor,
|
46
|
-
[ cursor, keys.map{|key| strip_namespace(key) } ]
|
46
|
+
def scan(cursor, match: nil, **kwargs)
|
47
|
+
if match
|
48
|
+
namespace(match) do |pattern|
|
49
|
+
cursor, keys = super(cursor, match: pattern, **kwargs)
|
50
|
+
[ cursor, keys.map{ |key| strip_namespace(key) } ]
|
47
51
|
end
|
48
52
|
else
|
49
|
-
super(cursor,
|
53
|
+
super(cursor, **kwargs)
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
@@ -74,34 +78,70 @@ class Redis
|
|
74
78
|
end
|
75
79
|
end
|
76
80
|
|
81
|
+
def expire(key, ttl)
|
82
|
+
namespace(key) { |k| super(k, ttl) }
|
83
|
+
end
|
84
|
+
|
85
|
+
def hdel(key, *fields)
|
86
|
+
namespace(key) { |k| super(k, *fields) }
|
87
|
+
end
|
88
|
+
|
89
|
+
def hget(key, field)
|
90
|
+
namespace(key) { |k| super(k, field) }
|
91
|
+
end
|
92
|
+
|
77
93
|
def hgetall(key)
|
78
94
|
namespace(key) { |k| super(k) }
|
79
95
|
end
|
80
96
|
|
81
|
-
def
|
82
|
-
namespace(key) { |k| super(k, field
|
97
|
+
def hexists(key, field)
|
98
|
+
namespace(key) { |k| super(k, field) }
|
83
99
|
end
|
84
100
|
|
85
|
-
def
|
86
|
-
namespace(key) { |k| super(k, field,
|
101
|
+
def hincrby(key, field, increment)
|
102
|
+
namespace(key) { |k| super(k, field, increment) }
|
87
103
|
end
|
88
104
|
|
89
|
-
def
|
90
|
-
namespace(key) { |k| super(k,
|
105
|
+
def hincrbyfloat(key, field, increment)
|
106
|
+
namespace(key) { |k| super(k, field, increment) }
|
91
107
|
end
|
92
108
|
|
93
|
-
def
|
94
|
-
namespace(key) { |k| super(k
|
109
|
+
def hkeys(key)
|
110
|
+
namespace(key) { |k| super(k) }
|
95
111
|
end
|
96
112
|
|
97
|
-
def
|
98
|
-
namespace(key) { |k| super(k
|
113
|
+
def hlen(key)
|
114
|
+
namespace(key) { |k| super(k) }
|
99
115
|
end
|
100
116
|
|
101
|
-
def
|
117
|
+
def hmget(key, *fields, &blk)
|
118
|
+
namespace(key) { |k| super(k, *fields, &blk) }
|
119
|
+
end
|
120
|
+
|
121
|
+
def hmset(key, *attrs)
|
122
|
+
namespace(key) { |k| super(k, *attrs) }
|
123
|
+
end
|
124
|
+
|
125
|
+
def hset(key, *args)
|
126
|
+
namespace(key) { |k| super(k, *args) }
|
127
|
+
end
|
128
|
+
|
129
|
+
def hsetnx(key, field, val)
|
130
|
+
namespace(key) { |k| super(k, field, val) }
|
131
|
+
end
|
132
|
+
|
133
|
+
def hvals(key)
|
102
134
|
namespace(key) { |k| super(k) }
|
103
135
|
end
|
104
136
|
|
137
|
+
def hscan(key, *args)
|
138
|
+
namespace(key) { |k| super(k, *args) }
|
139
|
+
end
|
140
|
+
|
141
|
+
def hscan_each(key, *args)
|
142
|
+
namespace(key) { |k| super(k, *args) }
|
143
|
+
end
|
144
|
+
|
105
145
|
def zincrby(key, increment, member)
|
106
146
|
namespace(key) { |k| super(k, increment, member) }
|
107
147
|
end
|
@@ -110,14 +150,18 @@ class Redis
|
|
110
150
|
namespace(key) { |k| super(k, member) }
|
111
151
|
end
|
112
152
|
|
113
|
-
def zadd(key,
|
114
|
-
namespace(key) { |k| super(k,
|
153
|
+
def zadd(key, *args)
|
154
|
+
namespace(key) { |k| super(k, *args) }
|
115
155
|
end
|
116
156
|
|
117
157
|
def zrem(key, member)
|
118
158
|
namespace(key) { |k| super(k, member) }
|
119
159
|
end
|
120
160
|
|
161
|
+
if respond_to?(:ruby2_keywords, true)
|
162
|
+
ruby2_keywords :set, :setex, :setnx, :hscan, :hscan_each
|
163
|
+
end
|
164
|
+
|
121
165
|
def to_s
|
122
166
|
if namespace_str
|
123
167
|
"#{super} with namespace #{namespace_str}"
|
data/lib/redis/store/version.rb
CHANGED
data/redis-store.gemspec
CHANGED
@@ -12,8 +12,6 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.summary = 'Redis stores for Ruby frameworks'
|
13
13
|
s.description = 'Namespaced Rack::Session, Rack::Cache, I18n and cache Redis stores for Ruby web frameworks.'
|
14
14
|
|
15
|
-
s.rubyforge_project = 'redis-store'
|
16
|
-
|
17
15
|
s.files = `git ls-files`.split("\n")
|
18
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
@@ -22,7 +20,7 @@ Gem::Specification.new do |s|
|
|
22
20
|
|
23
21
|
s.add_dependency 'redis', '>= 4', '< 5'
|
24
22
|
|
25
|
-
s.add_development_dependency 'rake', '
|
23
|
+
s.add_development_dependency 'rake', '>= 12.3.3'
|
26
24
|
s.add_development_dependency 'bundler'
|
27
25
|
s.add_development_dependency 'mocha', '~> 0.14.0'
|
28
26
|
s.add_development_dependency 'minitest', '~> 5'
|
@@ -194,14 +194,54 @@ describe "Redis::Store::Namespace" do
|
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
|
+
it "should namespace hdel" do
|
198
|
+
client.expects(:call).with([:hdel, "#{@namespace}:rabbit", "key1", "key2"]).once
|
199
|
+
store.hdel("rabbit", "key1", "key2")
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should namespace hget" do
|
203
|
+
client.expects(:call).with([:hget, "#{@namespace}:rabbit", "key"]).once
|
204
|
+
store.hget("rabbit", "key")
|
205
|
+
end
|
206
|
+
|
197
207
|
it "should namespace hgetall" do
|
198
208
|
client.expects(:call).with([:hgetall, "#{@namespace}:rabbit"]).once
|
199
209
|
store.hgetall("rabbit")
|
200
210
|
end
|
201
211
|
|
202
|
-
it "should namespace
|
203
|
-
client.expects(:call).with([:
|
204
|
-
store.
|
212
|
+
it "should namespace hexists" do
|
213
|
+
client.expects(:call).with([:hexists, "#{@namespace}:rabbit", "key"]).once
|
214
|
+
results = store.hexists("rabbit", "key")
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should namespace hincrby" do
|
218
|
+
client.expects(:call).with([:hincrby, "#{@namespace}:rabbit", "key", 1]).once
|
219
|
+
store.hincrby("rabbit", "key", 1)
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should namespace hincrbyfloat" do
|
223
|
+
client.expects(:call).with([:hincrby, "#{@namespace}:rabbit", "key", 1.5]).once
|
224
|
+
store.hincrby("rabbit", "key", 1.5)
|
225
|
+
end
|
226
|
+
|
227
|
+
it "should namespace hkeys" do
|
228
|
+
client.expects(:call).with([:hkeys, "#{@namespace}:rabbit"])
|
229
|
+
store.hkeys("rabbit")
|
230
|
+
end
|
231
|
+
|
232
|
+
it "should namespace hlen" do
|
233
|
+
client.expects(:call).with([:hlen, "#{@namespace}:rabbit"])
|
234
|
+
store.hlen("rabbit")
|
235
|
+
end
|
236
|
+
|
237
|
+
it "should namespace hmget" do
|
238
|
+
client.expects(:call).with([:hmget, "#{@namespace}:rabbit", "key1", "key2"])
|
239
|
+
store.hmget("rabbit", "key1", "key2")
|
240
|
+
end
|
241
|
+
|
242
|
+
it "should namespace hmset" do
|
243
|
+
client.expects(:call).with([:hmset, "#{@namespace}:rabbit", "key", @rabbit])
|
244
|
+
store.hmset("rabbit", "key", @rabbit)
|
205
245
|
end
|
206
246
|
|
207
247
|
it "should namespace hset" do
|
@@ -209,27 +249,44 @@ describe "Redis::Store::Namespace" do
|
|
209
249
|
store.hset("rabbit", "key", @rabbit)
|
210
250
|
end
|
211
251
|
|
252
|
+
it "should namespace hsetnx" do
|
253
|
+
client.expects(:call).with([:hsetnx, "#{@namespace}:rabbit", "key", @rabbit])
|
254
|
+
store.hsetnx("rabbit", "key", @rabbit)
|
255
|
+
end
|
256
|
+
|
257
|
+
it "should namespace hvals" do
|
258
|
+
client.expects(:call).with([:hvals, "#{@namespace}:rabbit"])
|
259
|
+
store.hvals("rabbit")
|
260
|
+
end
|
261
|
+
|
212
262
|
it "should namespace hscan" do
|
213
263
|
client.expects(:call).with([:hscan, "#{@namespace}:rabbit", 0])
|
214
264
|
store.hscan("rabbit", 0)
|
215
265
|
end
|
216
266
|
|
217
|
-
it "should namespace
|
218
|
-
client.
|
219
|
-
|
267
|
+
it "should namespace hscan_each with block" do
|
268
|
+
client.call([:hset, "#{@namespace}:rabbit", "key1", @rabbit])
|
269
|
+
client.expects(:call).with([:hscan, "#{@namespace}:rabbit", 0]).returns(["0", ["key1"]])
|
270
|
+
results = []
|
271
|
+
store.hscan_each("rabbit") do |key|
|
272
|
+
results << key
|
273
|
+
end
|
274
|
+
results.must_equal(["key1"])
|
220
275
|
end
|
221
276
|
|
222
|
-
it "should namespace
|
223
|
-
client.
|
224
|
-
|
277
|
+
it "should namespace hscan_each without block" do
|
278
|
+
client.call([:hset, "#{@namespace}:rabbit", "key1", @rabbit])
|
279
|
+
client.expects(:call).with([:hscan, "#{@namespace}:rabbit", 0]).returns(["0", ["key1"]])
|
280
|
+
results = store.hscan_each("rabbit").to_a
|
281
|
+
results.must_equal(["key1"])
|
225
282
|
end
|
226
283
|
|
227
|
-
it "should namespace zincrby" do
|
284
|
+
it "should namespace zincrby" do
|
228
285
|
client.expects(:call).with([:zincrby, "#{@namespace}:rabbit", 1.0, "member"])
|
229
286
|
store.zincrby("rabbit", 1.0, "member")
|
230
287
|
end
|
231
288
|
|
232
|
-
it "should namespace zscore" do
|
289
|
+
it "should namespace zscore" do
|
233
290
|
client.expects(:call).with([:zscore, "#{@namespace}:rabbit", "member"])
|
234
291
|
store.zscore("rabbit", "member")
|
235
292
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -34,16 +34,16 @@ dependencies:
|
|
34
34
|
name: rake
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "
|
37
|
+
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
39
|
+
version: 12.3.3
|
40
40
|
type: :development
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - "
|
44
|
+
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
version: 12.3.3
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,7 +190,8 @@ files:
|
|
190
190
|
- MIT-LICENSE
|
191
191
|
- README.md
|
192
192
|
- Rakefile
|
193
|
-
- gemfiles/
|
193
|
+
- gemfiles/redis_4_0_x.gemfile
|
194
|
+
- gemfiles/redis_4_1_x.gemfile
|
194
195
|
- gemfiles/redis_4_x.gemfile
|
195
196
|
- lib/redis-store.rb
|
196
197
|
- lib/redis/distributed_store.rb
|
@@ -232,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
232
233
|
- !ruby/object:Gem::Version
|
233
234
|
version: '0'
|
234
235
|
requirements: []
|
235
|
-
rubygems_version: 3.
|
236
|
+
rubygems_version: 3.1.2
|
236
237
|
signing_key:
|
237
238
|
specification_version: 4
|
238
239
|
summary: Redis stores for Ruby frameworks
|