redis-store 1.8.0 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 48f4ede21caf667a2743c9827827292d2aa83be7
4
- data.tar.gz: 33ba8ec50c9e700474a71b7a8d00be54d35dc093
2
+ SHA256:
3
+ metadata.gz: f1313af60d82044041ee37781a16eb734332476e45ce6bc59d6c2ffa4e90c1d5
4
+ data.tar.gz: b17aa7cf4cc0439c2e1ee460dd15c4f16a43963370a742c9a3c9180dc970d5dc
5
5
  SHA512:
6
- metadata.gz: 14df20e6fb35c1d6af7958b9fd2879087d98a578e8fb0c576f4884b69615c4af68b987a446ef8de7fb52ed51de76717b90cb2e2a290341f8dc7e29b3381a8ea7
7
- data.tar.gz: cbc94b8900774f3723b6cf03b6bd4e0be1931d1620ea9d97f04b52e2d8c92f813a1c7a40fd66dda808358f68db6eaf8b735950c9f1512aed0cbd0593031ef252
6
+ metadata.gz: ff9ea84a0b8daf75b59883ab6d2040a3726caaf43249d52661d1d9aa335ac2c25c7e53c351d45c81f2009b50a34d07bbe6a3d408d2701bdc7c7301959c2cb4dc
7
+ data.tar.gz: bccc369d3d57af1dcec02e1797b1e8527b3993c051c6ff3db60556638529630adbc3ba5a7b4d53b08ebe991f145abb7eaac37873fac734ca6c4bd6ec0ea31074
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
@@ -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
data/CHANGELOG.md CHANGED
@@ -1,5 +1,63 @@
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
+
33
+ ## 1.8.1
34
+
35
+ Breaking Changes
36
+
37
+ * None
38
+
39
+ Added
40
+
41
+ * None
42
+
43
+ Fixed
44
+
45
+ * [Add namespace to remaining hash methods](https://github.com/redis-store/redis-store/pull/321)
46
+
47
+ ## 1.8.0
48
+
49
+ Breaking Changes
50
+
51
+ * None
52
+
53
+ Added
54
+
55
+ * [Redis Cluster Support](https://github.com/redis-store/redis-store/pull/318)
56
+
57
+ Fixed
58
+
59
+ * None
60
+
3
61
  ## 1.6.0
4
62
 
5
63
  Breaking Changes
@@ -59,7 +117,7 @@ Added
59
117
 
60
118
  Fixed
61
119
 
62
- * Conventional `Marshal.dump` usage allowing potential security vulnerability (CVE-2017-1000248)
120
+ * Conventional `Marshal.dump` usage allowing potential security vulnerability (CVE-2017-1000248)
63
121
 
64
122
  ## 1.3.0
65
123
 
data/README.md CHANGED
@@ -45,9 +45,9 @@ s.add_dependency 'redis-store', '>= 1.4', '< 2'
45
45
 
46
46
  ## Status
47
47
 
48
- [![Gem Version](https://badge.fury.io/rb/redis-store.png)](http://badge.fury.io/rb/redis-store)
49
- [![Build Status](https://secure.travis-ci.org/redis-store/redis-store.png?branch=master)](http://travis-ci.org/redis-store/redis-store?branch=master)
50
- [![Code Climate](https://codeclimate.com/github/redis-store/redis-store.png)](https://codeclimate.com/github/redis-store/redis-store)
48
+ [![Gem Version](https://badge.fury.io/rb/redis-store.svg)](http://badge.fury.io/rb/redis-store)
49
+ [![Build Status](https://secure.travis-ci.org/redis-store/redis-store.svg?branch=master)](http://travis-ci.org/redis-store/redis-store?branch=master)
50
+ [![Code Climate](https://codeclimate.com/github/redis-store/redis-store.svg)](https://codeclimate.com/github/redis-store/redis-store)
51
51
 
52
52
  ## Copyright
53
53
 
@@ -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,20 +78,88 @@ 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
 
97
+ def hexists(key, field)
98
+ namespace(key) { |k| super(k, field) }
99
+ end
100
+
101
+ def hincrby(key, field, increment)
102
+ namespace(key) { |k| super(k, field, increment) }
103
+ end
104
+
105
+ def hincrbyfloat(key, field, increment)
106
+ namespace(key) { |k| super(k, field, increment) }
107
+ end
108
+
109
+ def hkeys(key)
110
+ namespace(key) { |k| super(k) }
111
+ end
112
+
113
+ def hlen(key)
114
+ namespace(key) { |k| super(k) }
115
+ end
116
+
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
+
81
129
  def hsetnx(key, field, val)
82
130
  namespace(key) { |k| super(k, field, val) }
83
131
  end
84
132
 
85
- def hset(key, field, val)
86
- namespace(key) { |k| super(k, field, val) }
133
+ def hvals(key)
134
+ namespace(key) { |k| super(k) }
87
135
  end
88
136
 
89
- def expire(key, ttl)
90
- namespace(key) { |k| super(k, ttl) }
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
+
145
+ def zincrby(key, increment, member)
146
+ namespace(key) { |k| super(k, increment, member) }
147
+ end
148
+
149
+ def zscore(key, member)
150
+ namespace(key) { |k| super(k, member) }
151
+ end
152
+
153
+ def zadd(key, *args)
154
+ namespace(key) { |k| super(k, *args) }
155
+ end
156
+
157
+ def zrem(key, member)
158
+ namespace(key) { |k| super(k, member) }
159
+ end
160
+
161
+ if respond_to?(:ruby2_keywords, true)
162
+ ruby2_keywords :set, :setex, :setnx, :hscan, :hscan_each
91
163
  end
92
164
 
93
165
  def to_s
@@ -19,9 +19,9 @@ class Redis
19
19
 
20
20
  protected
21
21
  def setnx_with_expire(key, value, ttl, options = {})
22
- with_multi_or_pipelined(options) do
23
- setnx(key, value, :raw => true)
24
- expire(key, ttl)
22
+ with_multi_or_pipelined(options) do |transaction|
23
+ transaction.setnx(key, value, :raw => true)
24
+ transaction.expire(key, ttl)
25
25
  end
26
26
  end
27
27
 
@@ -1,5 +1,5 @@
1
1
  class Redis
2
2
  class Store < self
3
- VERSION = '1.8.0'
3
+ VERSION = '1.9.1'
4
4
  end
5
5
  end
data/redis-store.gemspec CHANGED
@@ -12,17 +12,13 @@ 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
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
- s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
20
16
  s.require_paths = ["lib"]
21
17
  s.license = 'MIT'
22
18
 
23
19
  s.add_dependency 'redis', '>= 4', '< 5'
24
20
 
25
- s.add_development_dependency 'rake', '~> 10'
21
+ s.add_development_dependency 'rake', '>= 12.3.3'
26
22
  s.add_development_dependency 'bundler'
27
23
  s.add_development_dependency 'mocha', '~> 0.14.0'
28
24
  s.add_development_dependency 'minitest', '~> 5'
@@ -194,19 +194,111 @@ 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
208
248
  client.expects(:call).with([:hset, "#{@namespace}:rabbit", "key", @rabbit])
209
249
  store.hset("rabbit", "key", @rabbit)
210
250
  end
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
+
262
+ it "should namespace hscan" do
263
+ client.expects(:call).with([:hscan, "#{@namespace}:rabbit", 0])
264
+ store.hscan("rabbit", 0)
265
+ end
266
+
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"])
275
+ end
276
+
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"])
282
+ end
283
+
284
+ it "should namespace zincrby" do
285
+ client.expects(:call).with([:zincrby, "#{@namespace}:rabbit", 1.0, "member"])
286
+ store.zincrby("rabbit", 1.0, "member")
287
+ end
288
+
289
+ it "should namespace zscore" do
290
+ client.expects(:call).with([:zscore, "#{@namespace}:rabbit", "member"])
291
+ store.zscore("rabbit", "member")
292
+ end
293
+
294
+ it "should namespace zadd" do
295
+ client.expects(:call).with([:zadd, "#{@namespace}:rabbit", 1.0, "member"])
296
+ store.zadd("rabbit", 1.0, "member")
297
+ end
298
+
299
+ it "should namespace zrem" do
300
+ client.expects(:call).with([:zrem, "#{@namespace}:rabbit", "member"])
301
+ store.zrem("rabbit", "member")
302
+ end
211
303
  end
212
304
  end
@@ -38,7 +38,7 @@ class MockRedis
38
38
  @setnxes << a
39
39
  end
40
40
 
41
- block.call
41
+ block.call(self)
42
42
  end
43
43
  end
44
44
  alias_method :pipelined, :multi
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.0
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-18 00:00:00.000000000 Z
11
+ date: 2022-01-24 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
@@ -217,7 +218,7 @@ homepage: http://redis-store.org/redis-store
217
218
  licenses:
218
219
  - MIT
219
220
  metadata: {}
220
- post_install_message:
221
+ post_install_message:
221
222
  rdoc_options: []
222
223
  require_paths:
223
224
  - lib
@@ -232,19 +233,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
233
  - !ruby/object:Gem::Version
233
234
  version: '0'
234
235
  requirements: []
235
- rubyforge_project: redis-store
236
- rubygems_version: 2.6.14
237
- signing_key:
236
+ rubygems_version: 3.1.2
237
+ signing_key:
238
238
  specification_version: 4
239
239
  summary: Redis stores for Ruby frameworks
240
- test_files:
241
- - test/redis/distributed_store_test.rb
242
- - test/redis/store/factory_test.rb
243
- - test/redis/store/interface_test.rb
244
- - test/redis/store/namespace_test.rb
245
- - test/redis/store/redis_version_test.rb
246
- - test/redis/store/serialization_test.rb
247
- - test/redis/store/ttl_test.rb
248
- - test/redis/store/version_test.rb
249
- - test/redis/store_test.rb
250
- - test/test_helper.rb
240
+ test_files: []