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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6a10a3762b8378dd9efe3a4d1b41220691224b6f45fc6af2b06874fe1670cbf
4
- data.tar.gz: f81892b9c196e999bde41136a0fbb667e8ff5ddec7c16842afe86847b2872f71
3
+ metadata.gz: 476790788b3d0462db696bc3773a72c18b3f57f04db394e238bc849b04f6b54a
4
+ data.tar.gz: 443eca0ff3f6acd16c696aadf4e8cb1c34edf213944d489d66fe6508a5ff2390
5
5
  SHA512:
6
- metadata.gz: 8a63ad83287d6bc1249ce4980300745cf68243c61c274014b20f49bf0f395e3eb2b0b6e8899217fbf1d14792afc0f6ff54ca82844af1de5ab3a63fdf02fa2d27
7
- data.tar.gz: 9d834c549cbf74c18d1f9042216f10016fcb6b2115f3784c03fdc19923bd189382ac1dd88cd658524fe9e9579f24afb0ef25e8d005ce718a1b0441345856e0f1
6
+ metadata.gz: 104215ff505c8dd84b0baac16c99a75e117b33dafbc0f654f6f87acbf0fba1b0a1c34ce3e63530566f65289ca725a98b1e0a640cfc878f33e27fb51857a243df
7
+ data.tar.gz: 49730d0bc9e9a1295aaa6b410cae27c58838f953a71fb6255c53e27dc4faa670b827effbe2d0f614d4d4dfbe5f91b333465c380db44475c466f261d534e2d91c
@@ -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
@@ -1,6 +1,10 @@
1
1
 
2
- appraise "redis_3_x" do
3
- gem "redis", "~> 3.0"
2
+ appraise "redis_4_0_x" do
3
+ gem "redis", "~> 4.0.0"
4
+ end
5
+
6
+ appraise "redis_4_1_x" do
7
+ gem "redis", "~> 4.1.0"
4
8
  end
5
9
 
6
10
  appraise "redis_4_x" do
@@ -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
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "redis", "~> 3.0"
5
+ gem "redis", "~> 4.0.0"
6
6
 
7
7
  gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "redis", "~> 4.1.0"
6
+
7
+ gemspec path: "../"
@@ -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
- super(key, value, options || {})
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, val, options = nil)
7
- namespace(key) { |k| super(k, val, options) }
6
+ def set(key, *args)
7
+ namespace(key) { |k| super(k, *args) }
8
8
  end
9
9
 
10
- def setex(key, ttl, val, options = nil)
11
- namespace(key) { |k| super(k, ttl, val, options) }
10
+ def setex(key, *args)
11
+ namespace(key) { |k| super(k, *args) }
12
12
  end
13
13
 
14
- def setnx(key, val, options = nil)
15
- namespace(key) { |k| super(k, val, options) }
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, options = nil)
23
- namespace(key) { |k| super(k, options) }
22
+ def get(key, *args)
23
+ namespace(key) { |k| super(k, *args) }
24
24
  end
25
25
 
26
- def exists(key)
27
- namespace(key) { |k| super(k) }
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, options = {})
43
- if options[:match]
44
- namespace(options[:match]) do |pattern|
45
- cursor, keys = super(cursor, options.merge(match: pattern))
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, options)
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 hsetnx(key, field, val)
82
- namespace(key) { |k| super(k, field, val) }
97
+ def hexists(key, field)
98
+ namespace(key) { |k| super(k, field) }
83
99
  end
84
100
 
85
- def hset(key, field, val)
86
- namespace(key) { |k| super(k, field, val) }
101
+ def hincrby(key, field, increment)
102
+ namespace(key) { |k| super(k, field, increment) }
87
103
  end
88
104
 
89
- def expire(key, ttl)
90
- namespace(key) { |k| super(k, ttl) }
105
+ def hincrbyfloat(key, field, increment)
106
+ namespace(key) { |k| super(k, field, increment) }
91
107
  end
92
108
 
93
- def hscan(key, cursor, options = {})
94
- namespace(key) { |k| super(k, cursor, options) }
109
+ def hkeys(key)
110
+ namespace(key) { |k| super(k) }
95
111
  end
96
112
 
97
- def hdel(key, *fields)
98
- namespace(key) { |k| super(k, fields) }
113
+ def hlen(key)
114
+ namespace(key) { |k| super(k) }
99
115
  end
100
116
 
101
- def hlen(key)
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, increment, member)
114
- namespace(key) { |k| super(k, increment, member) }
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}"
@@ -1,5 +1,5 @@
1
1
  class Redis
2
2
  class Store < self
3
- VERSION = '1.8.2'
3
+ VERSION = '1.9.0'
4
4
  end
5
5
  end
@@ -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', '~> 10'
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 hsetnx" do
203
- client.expects(:call).with([:hsetnx, "#{@namespace}:rabbit", "key", @rabbit])
204
- store.hsetnx("rabbit", "key", @rabbit)
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 hdel" do
218
- client.expects(:call).with([:hdel, "#{@namespace}:rabbit", %w(field)])
219
- store.hdel("rabbit", "field")
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 hlen" do
223
- client.expects(:call).with([:hlen, "#{@namespace}:rabbit"])
224
- store.hlen("rabbit")
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.8.2
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-02-24 00:00:00.000000000 Z
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: '10'
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: '10'
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/redis_3_x.gemfile
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.0.3
236
+ rubygems_version: 3.1.2
236
237
  signing_key:
237
238
  specification_version: 4
238
239
  summary: Redis stores for Ruby frameworks