redis-store 1.9.2 → 1.10.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: 7a70e9a1e720591e28f5abee4cbfff877503f808a9318143234579ea942dc073
4
- data.tar.gz: 037aa5824d933374d37e0f922c8992034ed48d05bf00069be6040d52a6706b2e
3
+ metadata.gz: 90b9775d198eedd8f7fbfbf48548ea825bf888a80bf430be0b7124d9092b6f7a
4
+ data.tar.gz: bfa57fa72dafc2bf60885da2501cd377eaceb45892a5e21ca9515d378556f95a
5
5
  SHA512:
6
- metadata.gz: fe1f61f58277a706a19100e85433bd7177b23b8245c6f1354cbe49abdcb2aa9abed9a3956686b074d5c9edb7006f5dbb8f8715d579f316832eecf711a656dab1
7
- data.tar.gz: 22d18ed2621e2075d2e02a7f830d4ad2de45f834405f62650e9f41f19bff6b6d3a5017d1247fe0de893e5d3c21f71c3aed63f742c8823d05bef5cf6148c74c4d
6
+ metadata.gz: c4c0e067c7e20907158913fa39dbc86abc5c5b3a8120f966e2f311dcb3ae380596c824d0bfcb9385ca77681e8fb98d06ff63f45c289dfb51a1916d5448fe7ab4
7
+ data.tar.gz: d6e2d2bc963b99870f4a4abe0e20ede46dc3177f214685922aa0313e8baa9f2879d1fadd1d7786b5ce6d7dc9b736ee7a1ee74664041bbf4479347e96c44b0421
@@ -1,5 +1,6 @@
1
1
  name: CI
2
2
  on:
3
+ pull_request:
3
4
  push:
4
5
  branches-ignore: [master]
5
6
  tags-ignore: [v*]
@@ -27,6 +28,7 @@ jobs:
27
28
  - 4_0_x
28
29
  - 4_1_x
29
30
  - 4_x
31
+ - 5_x
30
32
  env:
31
33
  BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/redis_${{ matrix.redis }}.gemfile
32
34
  services:
@@ -15,7 +15,7 @@ jobs:
15
15
  - uses: ruby/setup-ruby@v1
16
16
  with:
17
17
  ruby-version: "3.1"
18
- bundler-cache: true
18
+ bundle-cache: true
19
19
  - run: |
20
20
  mkdir -p ~/.gem
21
21
  cat << EOF > ~/.gem/credentials
data/.gitignore CHANGED
@@ -4,3 +4,6 @@ tmp/
4
4
  stdout
5
5
  # Gemfile locks generated by Appraisals
6
6
  gemfiles/*.gemfile.lock
7
+ gemfiles/.bundle/
8
+ # ASDF
9
+ .tool-versions
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.10.0 and future
4
+
5
+ As at 1.10 and above, changelog information will be on this project's releases page:
6
+
7
+ https://github.com/redis-store/redis-store/releases
8
+
9
+
3
10
  ## 1.9.0
4
11
 
5
12
  Breaking Changes
data/README.md CHANGED
@@ -46,7 +46,7 @@ s.add_dependency 'redis-store', '>= 1.4', '< 2'
46
46
  ## Status
47
47
 
48
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)
49
+ [![Build Status](https://github.com/redis-store/redis-store/actions/workflows/ci.yml/badge.svg)](https://github.com/redis-store/redis-store/actions/workflows/ci.yml)
50
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
data/Rakefile CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'bundler/setup'
2
2
  require 'rake'
3
3
  require 'bundler/gem_tasks'
4
- require 'redis-store/testing/tasks'
5
4
  require 'appraisal'
6
5
  require 'rubocop/rake_task'
7
6
 
@@ -11,4 +10,6 @@ if !ENV["APPRAISAL_INITIALIZED"] && !ENV["CI"]
11
10
  task :default do
12
11
  sh "appraisal install && rake appraisal default"
13
12
  end
13
+ else
14
+ require 'redis-store/testing/tasks'
14
15
  end
@@ -7,6 +7,8 @@ class Redis
7
7
 
8
8
  def initialize(addresses, options = {})
9
9
  _extend_namespace options
10
+ # `@tag` introduced in `redis-rb` 5.0
11
+ @tag = options[:tag] || /^\{(.+?)\}/
10
12
  @ring = options[:ring] || Redis::HashRing.new([], options[:replicas] || Redis::HashRing::POINTS_PER_SERVER)
11
13
 
12
14
  addresses.each do |address|
@@ -1,3 +1,4 @@
1
+ require 'cgi'
1
2
  require 'uri'
2
3
 
3
4
  class Redis
@@ -1,5 +1,12 @@
1
1
  class Redis
2
2
  class Store < self
3
- VERSION = '1.9.2'
3
+ VERSION = '1.10.0'
4
+
5
+ def self.redis_client_defined?
6
+ # Doesn't work if declared as constant
7
+ # due to unpredictable gem loading order
8
+ # https://github.com/redis-rb/redis-client
9
+ defined?(::RedisClient::VERSION)
10
+ end
4
11
  end
5
12
  end
data/lib/redis/store.rb CHANGED
@@ -14,9 +14,13 @@ class Redis
14
14
  include Ttl, Interface, RedisVersion
15
15
 
16
16
  def initialize(options = {})
17
- super
17
+ orig_options = options.dup
18
18
 
19
- unless options[:marshalling].nil?
19
+ _remove_unsupported_options(options)
20
+ # The options here is updated
21
+ super(options)
22
+
23
+ unless orig_options[:marshalling].nil?
20
24
  puts %(
21
25
  DEPRECATED: You are passing the :marshalling option, which has been
22
26
  replaced with `serializer: Marshal` to support pluggable serialization
@@ -27,14 +31,15 @@ class Redis
27
31
  )
28
32
  end
29
33
 
30
- @serializer = options.key?(:serializer) ? options[:serializer] : Marshal
34
+ @serializer = orig_options.key?(:serializer) ? orig_options.delete(:serializer) : Marshal
31
35
 
32
- unless options[:marshalling].nil?
33
- @serializer = options[:marshalling] ? Marshal : nil
36
+ unless orig_options[:marshalling].nil?
37
+ # `marshalling` only used here, might not be supported in `super`
38
+ @serializer = orig_options.delete(:marshalling) ? Marshal : nil
34
39
  end
35
40
 
36
- _extend_marshalling options
37
- _extend_namespace options
41
+ _extend_marshalling
42
+ _extend_namespace orig_options
38
43
  end
39
44
 
40
45
  def reconnect
@@ -56,7 +61,19 @@ class Redis
56
61
  end
57
62
 
58
63
  private
59
- def _extend_marshalling(options)
64
+ def _remove_unsupported_options(options)
65
+ return unless self.class.redis_client_defined?
66
+
67
+ # Unsupported keywords should be removed to avoid errors
68
+ # https://github.com/redis-rb/redis-client/blob/v0.13.0/lib/redis_client/config.rb#L21
69
+ options.delete(:raw)
70
+ options.delete(:serializer)
71
+ options.delete(:marshalling)
72
+ options.delete(:namespace)
73
+ options.delete(:scheme)
74
+ end
75
+
76
+ def _extend_marshalling
60
77
  extend Serialization unless @serializer.nil?
61
78
  end
62
79
 
data/redis-store.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.add_development_dependency 'rake', '>= 12.3.3'
22
22
  s.add_development_dependency 'bundler'
23
- s.add_development_dependency 'mocha', '~> 0.14.0'
23
+ s.add_development_dependency 'mocha', '~> 2.1.0'
24
24
  s.add_development_dependency 'minitest', '~> 5'
25
25
  s.add_development_dependency 'git', '~> 1.2'
26
26
  s.add_development_dependency 'pry-nav', '~> 0.2.4'
@@ -17,7 +17,7 @@ describe "Redis::DistributedStore" do
17
17
 
18
18
  it "accepts connection params" do
19
19
  dmr = Redis::DistributedStore.new [ :host => "localhost", :port => "6380", :db => "1" ]
20
- dmr.ring.nodes.size == 1
20
+ _(dmr.ring.nodes.size).must_equal(1)
21
21
  mr = dmr.ring.nodes.first
22
22
  _(mr.to_s).must_equal("Redis Client connected to localhost:6380 against DB 1")
23
23
  end
@@ -7,7 +7,8 @@ describe "Redis::Store::Factory" do
7
7
  it "instantiates Redis::Store" do
8
8
  store = Redis::Store::Factory.create
9
9
  _(store).must_be_kind_of(Redis::Store)
10
- _(store.to_s).must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0")
10
+ # `redis.rb` use different default host values in v4 & v5
11
+ _(store.to_s).must_match(%r{^Redis Client connected to (127.0.0.1|localhost):6379 against DB 0$})
11
12
  end
12
13
  end
13
14
 
@@ -24,7 +25,9 @@ describe "Redis::Store::Factory" do
24
25
 
25
26
  it "uses specified scheme" do
26
27
  store = Redis::Store::Factory.create :scheme => "rediss"
27
- _(store.instance_variable_get(:@client).scheme).must_equal('rediss')
28
+ client = store.instance_variable_get(:@client)
29
+ # `redis-client` does NOT have `scheme`
30
+ client.respond_to?(:scheme) && _(client.scheme).must_equal('rediss')
28
31
  end
29
32
 
30
33
  it "uses specified path" do
@@ -39,12 +42,14 @@ describe "Redis::Store::Factory" do
39
42
 
40
43
  it "uses specified namespace" do
41
44
  store = Redis::Store::Factory.create :namespace => "theplaylist"
42
- _(store.to_s).must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
45
+ # `redis.rb` use different default host values in v4 & v5
46
+ _(store.to_s).must_match(%r{^Redis Client connected to (127.0.0.1|localhost):6379 against DB 0 with namespace theplaylist$})
43
47
  end
44
48
 
45
49
  it "uses specified key_prefix as namespace" do
46
50
  store = Redis::Store::Factory.create :key_prefix => "theplaylist"
47
- _(store.to_s).must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
51
+ # `redis.rb` use different default host values in v4 & v5
52
+ _(store.to_s).must_match(%r{^Redis Client connected to (127.0.0.1|localhost):6379 against DB 0 with namespace theplaylist$})
48
53
  end
49
54
 
50
55
  it "uses specified password" do
@@ -65,19 +70,22 @@ describe "Redis::Store::Factory" do
65
70
  it "disables serialization" do
66
71
  store = Redis::Store::Factory.create :serializer => nil
67
72
  _(store.instance_variable_get(:@serializer)).must_be_nil
68
- _(store.instance_variable_get(:@options)[:raw]).must_equal(true)
73
+ # `raw` would be removed when `redis-client` is used
74
+ defined?(::RedisClient) || _(store.instance_variable_get(:@options)[:raw]).must_equal(true)
69
75
  end
70
76
 
71
77
  it "configures pluggable serialization backend" do
72
78
  store = Redis::Store::Factory.create :serializer => JSON
73
79
  _(store.instance_variable_get(:@serializer)).must_equal(JSON)
74
- _(store.instance_variable_get(:@options)[:raw]).must_equal(false)
80
+ # `raw` would be removed when `redis-client` is used
81
+ defined?(::RedisClient) || _(store.instance_variable_get(:@options)[:raw]).must_equal(false)
75
82
  end
76
83
 
77
84
  describe "defaults" do
78
85
  it "defaults to localhost if no host specified" do
79
86
  store = Redis::Store::Factory.create
80
- _(store.instance_variable_get(:@client).host).must_equal('127.0.0.1')
87
+ # `redis.rb` use different default host values in v4 & v5
88
+ _(store.instance_variable_get(:@client).host).must_match(%r{^127.0.0.1|localhost$})
81
89
  end
82
90
 
83
91
  it "defaults to 6379 if no port specified" do
@@ -87,7 +95,9 @@ describe "Redis::Store::Factory" do
87
95
 
88
96
  it "defaults to redis:// if no scheme specified" do
89
97
  store = Redis::Store::Factory.create
90
- _(store.instance_variable_get(:@client).scheme).must_equal('redis')
98
+ client = store.instance_variable_get(:@client)
99
+ # `redis-client` does NOT have `scheme`
100
+ client.respond_to?(:scheme) && _(client.scheme).must_equal('redis')
91
101
  end
92
102
  end
93
103
 
@@ -103,13 +113,15 @@ describe "Redis::Store::Factory" do
103
113
  it "disables marshalling and provides deprecation warning" do
104
114
  store = Redis::Store::Factory.create :marshalling => false
105
115
  _(store.instance_variable_get(:@serializer)).must_be_nil
106
- _(store.instance_variable_get(:@options)[:raw]).must_equal(true)
116
+ # `raw` would be removed when `redis-client` is used
117
+ defined?(::RedisClient) || _(store.instance_variable_get(:@options)[:raw]).must_equal(true)
107
118
  end
108
119
 
109
120
  it "enables marshalling but provides warning to use :serializer instead" do
110
121
  store = Redis::Store::Factory.create :marshalling => true
111
122
  _(store.instance_variable_get(:@serializer)).must_equal(Marshal)
112
- _(store.instance_variable_get(:@options)[:raw]).must_equal(false)
123
+ # `raw` would be removed when `redis-client` is used
124
+ defined?(::RedisClient) || _(store.instance_variable_get(:@options)[:raw]).must_equal(false)
113
125
  end
114
126
 
115
127
  after do
@@ -144,12 +156,16 @@ describe "Redis::Store::Factory" do
144
156
 
145
157
  it "uses specified scheme" do
146
158
  store = Redis::Store::Factory.create "rediss://127.0.0.1:6380"
147
- _(store.instance_variable_get(:@client).scheme).must_equal('rediss')
159
+ client = store.instance_variable_get(:@client)
160
+ # `redis-client` does NOT have `scheme`
161
+ client.respond_to?(:scheme) && _(client.scheme).must_equal('rediss')
148
162
  end
149
163
 
150
164
  it "correctly defaults to redis:// when relative scheme specified" do
151
165
  store = Redis::Store::Factory.create "//127.0.0.1:6379"
152
- _(store.instance_variable_get(:@client).scheme).must_equal('redis')
166
+ client = store.instance_variable_get(:@client)
167
+ # `redis-client` does NOT have `scheme`
168
+ client.respond_to?(:scheme) && _(client.scheme).must_equal('redis')
153
169
  end
154
170
 
155
171
  it "uses specified path" do
@@ -215,7 +231,7 @@ describe "Redis::Store::Factory" do
215
231
 
216
232
  describe 'when given host Hash and options Hash' do
217
233
  it 'instantiates Redis::Store and merges options' do
218
- store = Redis::Store::Factory.create(
234
+ Redis::Store::Factory.create(
219
235
  { :host => '127.0.0.1', :port => '6379' },
220
236
  { :namespace => 'theplaylist' }
221
237
  )
@@ -249,7 +265,7 @@ describe "Redis::Store::Factory" do
249
265
  end
250
266
 
251
267
  it 'instantiates Redis::Store and sets namespace from String' do
252
- store = Redis::Store::Factory.create "redis://127.0.0.1:6379/0/theplaylist", :expire_after => 5
268
+ store = Redis::Store::Factory.create "redis://127.0.0.1:6379/0/theplaylist"
253
269
  _(store.to_s).must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
254
270
  end
255
271
  end
@@ -25,7 +25,9 @@ describe "Redis::Store::Namespace" do
25
25
  it "only decorates instances that need to be namespaced" do
26
26
  store = Redis::Store.new
27
27
  client = store.instance_variable_get(:@client)
28
- client.expects(:call).with([:get, "rabbit"])
28
+ # `call_v` used since redis-rb 5.0
29
+ client_call_method_name = client.respond_to?(:call_v) ? :call_v : :call
30
+ client.expects(client_call_method_name).with([:get, "rabbit"])
29
31
  store.get("rabbit")
30
32
  end
31
33
 
@@ -46,7 +48,8 @@ describe "Redis::Store::Namespace" do
46
48
  @default_store.set 'abc', 'cba'
47
49
  @other_store.set 'foo', 'bar'
48
50
 
49
- _(@default_store.keys.sort).must_equal ['abc', 'other:foo']
51
+ _(@default_store.keys).must_include('abc')
52
+ _(@default_store.keys).must_include('other:foo')
50
53
 
51
54
  @default_store.with_namespace(@other_namespace) do
52
55
  _(@default_store.keys).must_equal ['foo']
@@ -92,29 +95,33 @@ describe "Redis::Store::Namespace" do
92
95
  describe 'method calls' do
93
96
  let(:store) { Redis::Store.new :namespace => @namespace, :serializer => nil }
94
97
  let(:client) { store.instance_variable_get(:@client) }
98
+ let(:client_call_method_name) do
99
+ # `call_v` used since redis-rb 5.0
100
+ client.respond_to?(:call_v) ? :call_v : :call
101
+ end
95
102
 
96
103
  it "should namespace get" do
97
- client.expects(:call).with([:get, "#{@namespace}:rabbit"]).once
104
+ client.expects(client_call_method_name).with([:get, "#{@namespace}:rabbit"]).once
98
105
  store.get("rabbit")
99
106
  end
100
107
 
101
108
  it "should namespace set" do
102
- client.expects(:call).with([:set, "#{@namespace}:rabbit", @rabbit])
109
+ client.expects(client_call_method_name).with([:set, "#{@namespace}:rabbit", @rabbit])
103
110
  store.set "rabbit", @rabbit
104
111
  end
105
112
 
106
113
  it "should namespace setnx" do
107
- client.expects(:call).with([:setnx, "#{@namespace}:rabbit", @rabbit])
114
+ client.expects(client_call_method_name).with([:setnx, "#{@namespace}:rabbit", @rabbit])
108
115
  store.setnx "rabbit", @rabbit
109
116
  end
110
117
 
111
118
  it "should namespace del with single key" do
112
- client.expects(:call).with([:del, "#{@namespace}:rabbit"])
119
+ client.expects(client_call_method_name).with([:del, "#{@namespace}:rabbit"])
113
120
  store.del "rabbit"
114
121
  end
115
122
 
116
123
  it "should namespace del with multiple keys" do
117
- client.expects(:call).with([:del, "#{@namespace}:rabbit", "#{@namespace}:white_rabbit"])
124
+ client.expects(client_call_method_name).with([:del, "#{@namespace}:rabbit", "#{@namespace}:white_rabbit"])
118
125
  store.del "rabbit", "white_rabbit"
119
126
  end
120
127
 
@@ -135,29 +142,35 @@ describe "Redis::Store::Namespace" do
135
142
  end
136
143
 
137
144
  it "should namespace exists" do
138
- client.expects(:call).with([:exists, "#{@namespace}:rabbit"])
145
+ client.expects(client_call_method_name).with([:exists, "#{@namespace}:rabbit"])
139
146
  store.exists "rabbit"
140
147
  end
141
148
 
142
149
  it "should namespace incrby" do
143
- client.expects(:call).with([:incrby, "#{@namespace}:counter", 1])
150
+ client.expects(client_call_method_name).with([:incrby, "#{@namespace}:counter", 1])
144
151
  store.incrby "counter", 1
145
152
  end
146
153
 
147
154
  it "should namespace decrby" do
148
- client.expects(:call).with([:decrby, "#{@namespace}:counter", 1])
155
+ client.expects(client_call_method_name).with([:decrby, "#{@namespace}:counter", 1])
149
156
  store.decrby "counter", 1
150
157
  end
151
158
 
152
159
  it "should namespace mget" do
153
- client.expects(:call).with([:mget, "#{@namespace}:rabbit", "#{@namespace}:white_rabbit"]).returns(%w[ foo bar ])
160
+ client.expects(client_call_method_name).with([:mget, "#{@namespace}:rabbit", "#{@namespace}:white_rabbit"]).returns(%w[ foo bar ])
154
161
  store.mget "rabbit", "white_rabbit" do |result|
155
162
  _(result).must_equal(%w[ foo bar ])
156
163
  end
157
164
  end
158
165
 
159
166
  it "should namespace mapped_mget" do
160
- client.expects(:process).with([[:mget, "#{@namespace}:rabbit", "#{@namespace}:white_rabbit"]]).returns(%w[ foo bar ])
167
+ if client.respond_to?(:process, true)
168
+ # Redis < 5.0 uses `#process`
169
+ client.expects(:process).with([[:mget, "#{@namespace}:rabbit", "#{@namespace}:white_rabbit"]]).returns(%w[ foo bar ])
170
+ else
171
+ # Redis 5.x calls `#ensure_connected` (private)
172
+ client.send(:ensure_connected).expects(:call).returns(%w[ foo bar ])
173
+ end
161
174
  result = store.mapped_mget "rabbit", "white_rabbit"
162
175
  _(result.keys).must_equal %w[ rabbit white_rabbit ]
163
176
  _(result["rabbit"]).must_equal "foo"
@@ -165,108 +178,108 @@ describe "Redis::Store::Namespace" do
165
178
  end
166
179
 
167
180
  it "should namespace expire" do
168
- client.expects(:call).with([:expire, "#{@namespace}:rabbit", 60]).once
181
+ client.expects(client_call_method_name).with([:expire, "#{@namespace}:rabbit", 60]).once
169
182
  store.expire("rabbit", 60)
170
183
  end
171
184
 
172
185
  it "should namespace ttl" do
173
- client.expects(:call).with([:ttl, "#{@namespace}:rabbit"]).once
186
+ client.expects(client_call_method_name).with([:ttl, "#{@namespace}:rabbit"]).once
174
187
  store.ttl("rabbit")
175
188
  end
176
189
 
177
190
  it "should namespace watch" do
178
- client.expects(:call).with([:watch, "#{@namespace}:rabbit"]).once
191
+ client.expects(client_call_method_name).with([:watch, "#{@namespace}:rabbit"]).once
179
192
  store.watch("rabbit")
180
193
  end
181
194
 
182
195
  it "wraps flushdb with appropriate KEYS * calls" do
183
- client.expects(:call).with([:flushdb]).never
184
- client.expects(:call).with([:keys, "#{@namespace}:*"]).once.returns(["rabbit"])
185
- client.expects(:call).with([:del, "#{@namespace}:rabbit"]).once
196
+ client.expects(client_call_method_name).with([:flushdb]).never
197
+ client.expects(client_call_method_name).with([:keys, "#{@namespace}:*"]).once.returns(["rabbit"])
198
+ client.expects(client_call_method_name).with([:del, "#{@namespace}:rabbit"]).once
186
199
  store.flushdb
187
200
  end
188
201
 
189
202
  it "skips flushdb wrapping if the namespace is nil" do
190
- client.expects(:call).with([:flushdb])
191
- client.expects(:call).with([:keys]).never
203
+ client.expects(client_call_method_name).with([:flushdb])
204
+ client.expects(client_call_method_name).with([:keys]).never
192
205
  store.with_namespace(nil) do
193
206
  store.flushdb
194
207
  end
195
208
  end
196
209
 
197
210
  it "should namespace hdel" do
198
- client.expects(:call).with([:hdel, "#{@namespace}:rabbit", "key1", "key2"]).once
211
+ client.expects(client_call_method_name).with([:hdel, "#{@namespace}:rabbit", "key1", "key2"]).once
199
212
  store.hdel("rabbit", "key1", "key2")
200
213
  end
201
214
 
202
215
  it "should namespace hget" do
203
- client.expects(:call).with([:hget, "#{@namespace}:rabbit", "key"]).once
216
+ client.expects(client_call_method_name).with([:hget, "#{@namespace}:rabbit", "key"]).once
204
217
  store.hget("rabbit", "key")
205
218
  end
206
219
 
207
220
  it "should namespace hgetall" do
208
- client.expects(:call).with([:hgetall, "#{@namespace}:rabbit"]).once
221
+ client.expects(client_call_method_name).with([:hgetall, "#{@namespace}:rabbit"]).once
209
222
  store.hgetall("rabbit")
210
223
  end
211
224
 
212
225
  it "should namespace hexists" do
213
- client.expects(:call).with([:hexists, "#{@namespace}:rabbit", "key"]).once
214
- results = store.hexists("rabbit", "key")
226
+ client.expects(client_call_method_name).with([:hexists, "#{@namespace}:rabbit", "key"]).once
227
+ store.hexists("rabbit", "key")
215
228
  end
216
229
 
217
230
  it "should namespace hincrby" do
218
- client.expects(:call).with([:hincrby, "#{@namespace}:rabbit", "key", 1]).once
231
+ client.expects(client_call_method_name).with([:hincrby, "#{@namespace}:rabbit", "key", 1]).once
219
232
  store.hincrby("rabbit", "key", 1)
220
233
  end
221
234
 
222
235
  it "should namespace hincrbyfloat" do
223
- client.expects(:call).with([:hincrby, "#{@namespace}:rabbit", "key", 1.5]).once
224
- store.hincrby("rabbit", "key", 1.5)
236
+ client.expects(client_call_method_name).with([:hincrbyfloat, "#{@namespace}:rabbit", "key", 1.5]).once
237
+ store.hincrbyfloat("rabbit", "key", 1.5)
225
238
  end
226
239
 
227
240
  it "should namespace hkeys" do
228
- client.expects(:call).with([:hkeys, "#{@namespace}:rabbit"])
241
+ client.expects(client_call_method_name).with([:hkeys, "#{@namespace}:rabbit"])
229
242
  store.hkeys("rabbit")
230
243
  end
231
244
 
232
245
  it "should namespace hlen" do
233
- client.expects(:call).with([:hlen, "#{@namespace}:rabbit"])
246
+ client.expects(client_call_method_name).with([:hlen, "#{@namespace}:rabbit"])
234
247
  store.hlen("rabbit")
235
248
  end
236
249
 
237
250
  it "should namespace hmget" do
238
- client.expects(:call).with([:hmget, "#{@namespace}:rabbit", "key1", "key2"])
251
+ client.expects(client_call_method_name).with([:hmget, "#{@namespace}:rabbit", "key1", "key2"])
239
252
  store.hmget("rabbit", "key1", "key2")
240
253
  end
241
254
 
242
255
  it "should namespace hmset" do
243
- client.expects(:call).with([:hmset, "#{@namespace}:rabbit", "key", @rabbit])
256
+ client.expects(client_call_method_name).with([:hmset, "#{@namespace}:rabbit", "key", @rabbit])
244
257
  store.hmset("rabbit", "key", @rabbit)
245
258
  end
246
259
 
247
260
  it "should namespace hset" do
248
- client.expects(:call).with([:hset, "#{@namespace}:rabbit", "key", @rabbit])
261
+ client.expects(client_call_method_name).with([:hset, "#{@namespace}:rabbit", "key", @rabbit])
249
262
  store.hset("rabbit", "key", @rabbit)
250
263
  end
251
264
 
252
265
  it "should namespace hsetnx" do
253
- client.expects(:call).with([:hsetnx, "#{@namespace}:rabbit", "key", @rabbit])
266
+ client.expects(client_call_method_name).with([:hsetnx, "#{@namespace}:rabbit", "key", @rabbit])
254
267
  store.hsetnx("rabbit", "key", @rabbit)
255
268
  end
256
269
 
257
270
  it "should namespace hvals" do
258
- client.expects(:call).with([:hvals, "#{@namespace}:rabbit"])
271
+ client.expects(client_call_method_name).with([:hvals, "#{@namespace}:rabbit"])
259
272
  store.hvals("rabbit")
260
273
  end
261
274
 
262
275
  it "should namespace hscan" do
263
- client.expects(:call).with([:hscan, "#{@namespace}:rabbit", 0])
276
+ client.expects(client_call_method_name).with([:hscan, "#{@namespace}:rabbit", 0])
264
277
  store.hscan("rabbit", 0)
265
278
  end
266
279
 
267
280
  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"]])
281
+ client.public_send(client_call_method_name, [:hset, "#{@namespace}:rabbit", "key1", @rabbit])
282
+ client.expects(client_call_method_name).with([:hscan, "#{@namespace}:rabbit", 0]).returns(["0", ["key1"]])
270
283
  results = []
271
284
  store.hscan_each("rabbit") do |key|
272
285
  results << key
@@ -275,29 +288,29 @@ describe "Redis::Store::Namespace" do
275
288
  end
276
289
 
277
290
  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"]])
291
+ client.public_send(client_call_method_name, [:hset, "#{@namespace}:rabbit", "key1", @rabbit])
292
+ client.expects(client_call_method_name).with([:hscan, "#{@namespace}:rabbit", 0]).returns(["0", ["key1"]])
280
293
  results = store.hscan_each("rabbit").to_a
281
294
  _(results).must_equal(["key1"])
282
295
  end
283
296
 
284
297
  it "should namespace zincrby" do
285
- client.expects(:call).with([:zincrby, "#{@namespace}:rabbit", 1.0, "member"])
298
+ client.expects(client_call_method_name).with([:zincrby, "#{@namespace}:rabbit", 1.0, "member"])
286
299
  store.zincrby("rabbit", 1.0, "member")
287
300
  end
288
301
 
289
302
  it "should namespace zscore" do
290
- client.expects(:call).with([:zscore, "#{@namespace}:rabbit", "member"])
303
+ client.expects(client_call_method_name).with([:zscore, "#{@namespace}:rabbit", "member"])
291
304
  store.zscore("rabbit", "member")
292
305
  end
293
306
 
294
307
  it "should namespace zadd" do
295
- client.expects(:call).with([:zadd, "#{@namespace}:rabbit", 1.0, "member"])
308
+ client.expects(client_call_method_name).with([:zadd, "#{@namespace}:rabbit", 1.0, "member"])
296
309
  store.zadd("rabbit", 1.0, "member")
297
310
  end
298
311
 
299
312
  it "should namespace zrem" do
300
- client.expects(:call).with([:zrem, "#{@namespace}:rabbit", "member"])
313
+ client.expects(client_call_method_name).with([:zrem, "#{@namespace}:rabbit", "member"])
301
314
  store.zrem("rabbit", "member")
302
315
  end
303
316
  end
@@ -29,7 +29,7 @@ describe "Redis::Serialization" do
29
29
  _(@store.get("rabbit2")).must_equal(@rabbit)
30
30
  end
31
31
 
32
- if RUBY_VERSION.match /1\.9/
32
+ if RUBY_VERSION.match(/1\.9/)
33
33
  it "doesn't unmarshal on get if raw option is true" do
34
34
  _(@store.get("rabbit", :raw => true)).must_equal("\x04\bU:\x0FOpenStruct{\x06:\tnameI\"\nbunny\x06:\x06EF")
35
35
  end
@@ -117,7 +117,7 @@ describe "Redis::Serialization" do
117
117
  _(result["rabbit2"]).must_equal @white_rabbit
118
118
  end
119
119
 
120
- if RUBY_VERSION.match /1\.9/
120
+ if RUBY_VERSION.match(/1\.9/)
121
121
  it "doesn't unmarshal on multi get if raw option is true" do
122
122
  @store.set "rabbit2", @white_rabbit
123
123
  @store.mget "rabbit", "rabbit2", :raw => true do |rabbit, rabbit2|
@@ -43,7 +43,7 @@ describe Redis::Store do
43
43
  @store.del(key)
44
44
  _(@store.set(key, mock_value, {})).must_equal 'OK'
45
45
  _(@store.set(key, mock_value, {})).must_equal 'OK'
46
- _(@store.ttl(key)).must_equal -1
46
+ _(@store.ttl(key)).must_equal(-1)
47
47
 
48
48
  # with ex and nx options, the key can only be set once and a ttl will be set
49
49
  @store.del(key)
data/test/test_helper.rb CHANGED
@@ -1,9 +1,8 @@
1
1
  require 'bundler/setup'
2
2
  require 'minitest/autorun'
3
- require 'mocha/setup'
3
+ require 'mocha/minitest'
4
4
  require 'redis'
5
5
  require 'redis-store'
6
- require 'pry'
7
6
 
8
7
  $DEBUG = ENV["DEBUG"] === "true"
9
8
 
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.9.2
4
+ version: 1.10.0
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: 2023-02-24 00:00:00.000000000 Z
11
+ date: 2023-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: 0.14.0
67
+ version: 2.1.0
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: 0.14.0
74
+ version: 2.1.0
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: minitest
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -222,7 +222,7 @@ homepage: http://redis-store.org/redis-store
222
222
  licenses:
223
223
  - MIT
224
224
  metadata: {}
225
- post_install_message:
225
+ post_install_message:
226
226
  rdoc_options: []
227
227
  require_paths:
228
228
  - lib
@@ -237,8 +237,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
237
  - !ruby/object:Gem::Version
238
238
  version: '0'
239
239
  requirements: []
240
- rubygems_version: 3.3.26
241
- signing_key:
240
+ rubygems_version: 3.3.16
241
+ signing_key:
242
242
  specification_version: 4
243
243
  summary: Redis stores for Ruby frameworks
244
244
  test_files: []