redis-store 1.6.0 → 1.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,120 +15,122 @@ describe "Redis::Serialization" do
15
15
  end
16
16
 
17
17
  it "unmarshals on get" do
18
- @store.get("rabbit").must_equal(@rabbit)
18
+ _(@store.get("rabbit")).must_equal(@rabbit)
19
19
  end
20
20
 
21
21
  it "marshals on set" do
22
22
  @store.set "rabbit", @white_rabbit
23
- @store.get("rabbit").must_equal(@white_rabbit)
23
+ _(@store.get("rabbit")).must_equal(@white_rabbit)
24
24
  end
25
25
 
26
26
  it "marshals on multi set" do
27
27
  @store.mset("rabbit", @white_rabbit, "rabbit2", @rabbit)
28
- @store.get("rabbit").must_equal(@white_rabbit)
29
- @store.get("rabbit2").must_equal(@rabbit)
28
+ _(@store.get("rabbit")).must_equal(@white_rabbit)
29
+ _(@store.get("rabbit2")).must_equal(@rabbit)
30
30
  end
31
31
 
32
32
  if RUBY_VERSION.match /1\.9/
33
33
  it "doesn't unmarshal on get if raw option is true" do
34
- @store.get("rabbit", :raw => true).must_equal("\x04\bU:\x0FOpenStruct{\x06:\tnameI\"\nbunny\x06:\x06EF")
34
+ _(@store.get("rabbit", :raw => true)).must_equal("\x04\bU:\x0FOpenStruct{\x06:\tnameI\"\nbunny\x06:\x06EF")
35
35
  end
36
36
  else
37
37
  it "doesn't unmarshal on get if raw option is true" do
38
- @store.get("rabbit", :raw => true).must_include("\x04\bU:\x0FOpenStruct{\x06:\tname")
38
+ _(@store.get("rabbit", :raw => true)).must_include("\x04\bU:\x0FOpenStruct{\x06:\tname")
39
39
  end
40
40
  end
41
41
 
42
42
  it "doesn't marshal set if raw option is true" do
43
43
  @store.set "rabbit", @white_rabbit, :raw => true
44
- @store.get("rabbit", :raw => true).must_equal(%(#<OpenStruct color="white">))
44
+ _(@store.get("rabbit", :raw => true)).must_equal(%(#<OpenStruct color="white">))
45
45
  end
46
46
 
47
47
  it "doesn't marshal multi set if raw option is true" do
48
48
  @store.mset("rabbit", @white_rabbit, "rabbit2", @rabbit, :raw => true)
49
- @store.get("rabbit", :raw => true).must_equal(%(#<OpenStruct color="white">))
50
- @store.get("rabbit2", :raw => true).must_equal(%(#<OpenStruct name="bunny">))
49
+ _(@store.get("rabbit", :raw => true)).must_equal(%(#<OpenStruct color="white">))
50
+ _(@store.get("rabbit2", :raw => true)).must_equal(%(#<OpenStruct name="bunny">))
51
51
  end
52
52
 
53
53
  it "doesn't unmarshal if get returns an empty string" do
54
54
  @store.set "empty_string", ""
55
- @store.get("empty_string").must_equal("")
55
+ _(@store.get("empty_string")).must_equal("")
56
56
  # TODO use a meaningful Exception
57
57
  # lambda { @store.get("empty_string").must_equal("") }.wont_raise Exception
58
58
  end
59
59
 
60
60
  it "doesn't set an object if already exist" do
61
61
  @store.setnx "rabbit", @white_rabbit
62
- @store.get("rabbit").must_equal(@rabbit)
62
+ _(@store.get("rabbit")).must_equal(@rabbit)
63
63
  end
64
64
 
65
65
  it "marshals on set unless exists" do
66
66
  @store.setnx "rabbit2", @white_rabbit
67
- @store.get("rabbit2").must_equal(@white_rabbit)
67
+ _(@store.get("rabbit2")).must_equal(@white_rabbit)
68
68
  end
69
69
 
70
70
  it "doesn't marshal on set unless exists if raw option is true" do
71
71
  @store.setnx "rabbit2", @white_rabbit, :raw => true
72
- @store.get("rabbit2", :raw => true).must_equal(%(#<OpenStruct color="white">))
72
+ _(@store.get("rabbit2", :raw => true)).must_equal(%(#<OpenStruct color="white">))
73
73
  end
74
74
 
75
75
  it "marshals on set expire" do
76
76
  @store.setex "rabbit2", 1, @white_rabbit
77
- @store.get("rabbit2").must_equal(@white_rabbit)
77
+ _(@store.get("rabbit2")).must_equal(@white_rabbit)
78
78
  sleep 2
79
- @store.get("rabbit2").must_be_nil
79
+ _(@store.get("rabbit2")).must_be_nil
80
80
  end
81
81
 
82
- it "marshals setex (over a distributed store)" do
83
- @store = Redis::DistributedStore.new [
84
- { :host => "localhost", :port => "6380", :db => 0 },
85
- { :host => "localhost", :port => "6381", :db => 0 }
86
- ]
87
- @store.setex "rabbit", 50, @white_rabbit
88
- @store.get("rabbit").must_equal(@white_rabbit)
89
- end
82
+ unless ENV['CI']
83
+ it "marshals setex (over a distributed store)" do
84
+ @store = Redis::DistributedStore.new [
85
+ { :host => "localhost", :port => "6380", :db => 0 },
86
+ { :host => "localhost", :port => "6381", :db => 0 }
87
+ ]
88
+ @store.setex "rabbit", 50, @white_rabbit
89
+ _(@store.get("rabbit")).must_equal(@white_rabbit)
90
+ end
90
91
 
91
- it "doesn't marshal setex if raw option is true (over a distributed store)" do
92
- @store = Redis::DistributedStore.new [
93
- { :host => "localhost", :port => "6380", :db => 0 },
94
- { :host => "localhost", :port => "6381", :db => 0 }
95
- ]
96
- @store.setex "rabbit", 50, @white_rabbit, :raw => true
97
- @store.get("rabbit", :raw => true).must_equal(%(#<OpenStruct color="white">))
92
+ it "doesn't marshal setex if raw option is true (over a distributed store)" do
93
+ @store = Redis::DistributedStore.new [
94
+ { :host => "localhost", :port => "6380", :db => 0 },
95
+ { :host => "localhost", :port => "6381", :db => 0 }
96
+ ]
97
+ @store.setex "rabbit", 50, @white_rabbit, :raw => true
98
+ _(@store.get("rabbit", :raw => true)).must_equal(%(#<OpenStruct color="white">))
99
+ end
98
100
  end
99
101
 
100
102
  it "unmarshals on multi get" do
101
103
  @store.set "rabbit2", @white_rabbit
102
104
  @store.mget "rabbit", "rabbit2" do |rabbits|
103
105
  rabbit, rabbit2 = rabbits
104
- rabbits.length.must_equal(2)
105
- rabbit.must_equal(@rabbit)
106
- rabbit2.must_equal(@white_rabbit)
106
+ _(rabbits.length).must_equal(2)
107
+ _(rabbit).must_equal(@rabbit)
108
+ _(rabbit2).must_equal(@white_rabbit)
107
109
  end
108
110
  end
109
111
 
110
112
  it "unmarshals on mapped_mget" do
111
113
  @store.set "rabbit2", @white_rabbit
112
114
  result = @store.mapped_mget("rabbit", "rabbit2")
113
- result.keys.must_equal %w[ rabbit rabbit2 ]
114
- result["rabbit"].must_equal @rabbit
115
- result["rabbit2"].must_equal @white_rabbit
115
+ _(result.keys).must_equal %w[ rabbit rabbit2 ]
116
+ _(result["rabbit"]).must_equal @rabbit
117
+ _(result["rabbit2"]).must_equal @white_rabbit
116
118
  end
117
119
 
118
120
  if RUBY_VERSION.match /1\.9/
119
121
  it "doesn't unmarshal on multi get if raw option is true" do
120
122
  @store.set "rabbit2", @white_rabbit
121
123
  @store.mget "rabbit", "rabbit2", :raw => true do |rabbit, rabbit2|
122
- rabbit.must_equal("\x04\bU:\x0FOpenStruct{\x06:\tnameI\"\nbunny\x06:\x06EF")
123
- rabbit2.must_equal("\x04\bU:\x0FOpenStruct{\x06:\ncolorI\"\nwhite\x06:\x06EF")
124
+ _(rabbit).must_equal("\x04\bU:\x0FOpenStruct{\x06:\tnameI\"\nbunny\x06:\x06EF")
125
+ _(rabbit2).must_equal("\x04\bU:\x0FOpenStruct{\x06:\ncolorI\"\nwhite\x06:\x06EF")
124
126
  end
125
127
  end
126
128
  else
127
129
  it "doesn't unmarshal on multi get if raw option is true" do
128
130
  @store.set "rabbit2", @white_rabbit
129
131
  @store.mget "rabbit", "rabbit2", :raw => true do |rabbit, rabbit2|
130
- rabbit.must_include("\x04\bU:\x0FOpenStruct{\x06:\tname")
131
- rabbit2.must_include("\x04\bU:\x0FOpenStruct{\x06:\ncolor")
132
+ _(rabbit).must_include("\x04\bU:\x0FOpenStruct{\x06:\tname")
133
+ _(rabbit2).must_include("\x04\bU:\x0FOpenStruct{\x06:\ncolor")
132
134
  end
133
135
  end
134
136
  end
@@ -139,7 +141,7 @@ describe "Redis::Serialization" do
139
141
  ascii_rabbit = OpenStruct.new(:name => [128].pack("C*"))
140
142
 
141
143
  @store.set(utf8_key, ascii_rabbit)
142
- @store.get(utf8_key).must_equal(ascii_rabbit)
144
+ _(@store.get(utf8_key)).must_equal(ascii_rabbit)
143
145
  end
144
146
 
145
147
  it "gets and sets raw values" do
@@ -147,7 +149,7 @@ describe "Redis::Serialization" do
147
149
  ascii_string = [128].pack("C*")
148
150
 
149
151
  @store.set(utf8_key, ascii_string, :raw => true)
150
- @store.get(utf8_key, :raw => true).bytes.to_a.must_equal(ascii_string.bytes.to_a)
152
+ _(@store.get(utf8_key, :raw => true).bytes.to_a).must_equal(ascii_string.bytes.to_a)
151
153
  end
152
154
 
153
155
  it "marshals objects on setnx" do
@@ -156,7 +158,7 @@ describe "Redis::Serialization" do
156
158
 
157
159
  @store.del(utf8_key)
158
160
  @store.setnx(utf8_key, ascii_rabbit)
159
- @store.get(utf8_key).must_equal(ascii_rabbit)
161
+ _(@store.get(utf8_key)).must_equal(ascii_rabbit)
160
162
  end
161
163
 
162
164
  it "gets and sets raw values on setnx" do
@@ -165,7 +167,7 @@ describe "Redis::Serialization" do
165
167
 
166
168
  @store.del(utf8_key)
167
169
  @store.setnx(utf8_key, ascii_string, :raw => true)
168
- @store.get(utf8_key, :raw => true).bytes.to_a.must_equal(ascii_string.bytes.to_a)
170
+ _(@store.get(utf8_key, :raw => true).bytes.to_a).must_equal(ascii_string.bytes.to_a)
169
171
  end
170
172
  end if defined?(Encoding)
171
173
  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
@@ -66,14 +66,14 @@ describe MockTtlStore do
66
66
  describe 'without options' do
67
67
  it 'must call super with key and value' do
68
68
  redis.set(key, mock_value)
69
- redis.has_set?(key, mock_value, nil).must_equal true
69
+ _(redis.has_set?(key, mock_value, nil)).must_equal true
70
70
  end
71
71
  end
72
72
 
73
73
  describe 'with options' do
74
74
  it 'must call setex with proper expiry and set raw to true' do
75
75
  redis.set(key, mock_value, options)
76
- redis.has_setex?(key, options[:expire_after], mock_value, :raw => true).must_equal true
76
+ _(redis.has_setex?(key, options[:expire_after], mock_value, :raw => true)).must_equal true
77
77
  end
78
78
  end
79
79
 
@@ -81,7 +81,7 @@ describe MockTtlStore do
81
81
  it 'must call super with key and value and options' do
82
82
  set_options = { nx: true, ex: 3600 }
83
83
  redis.set(key, mock_value, set_options)
84
- redis.has_set?(key, mock_value, set_options).must_equal true
84
+ _(redis.has_set?(key, mock_value, set_options)).must_equal true
85
85
  end
86
86
  end
87
87
  end
@@ -105,14 +105,9 @@ describe MockTtlStore do
105
105
  redis.setnx(key, mock_value, options)
106
106
  end
107
107
 
108
- it 'must call setnx with key and value and set raw to true' do
109
- redis.setnx(key, mock_value, options)
110
- redis.has_setnx?(key, mock_value, :raw => true).must_equal true
111
- end
112
-
113
108
  it 'must call expire' do
114
109
  redis.setnx(key, mock_value, options)
115
- redis.has_expire?(key, options[:expire_after]).must_equal true
110
+ _(redis.has_expire?(key, options[:expire_after])).must_equal true
116
111
  end
117
112
 
118
113
  describe 'avoiding multi commands' do
@@ -123,14 +118,23 @@ describe MockTtlStore do
123
118
  redis.setnx(key, mock_value, options)
124
119
  end
125
120
 
126
- it 'must call setnx with key and value and set raw to true' do
121
+ it 'must call expire' do
122
+ redis.setnx(key, mock_value, options)
123
+ _(redis.has_expire?(key, options[:expire_after])).must_equal true
124
+ end
125
+ end
126
+
127
+ describe 'using a redis cluster' do
128
+ let(:options) { { :expire_after => 3600, :cluster => %w[redis://127.0.0.1:6379/0] } }
129
+
130
+ it 'uses the redis pipelined feature to chain commands' do
131
+ redis.expects(:pipelined)
127
132
  redis.setnx(key, mock_value, options)
128
- redis.has_setnx?(key, mock_value, :raw => true).must_equal true
129
133
  end
130
134
 
131
135
  it 'must call expire' do
132
136
  redis.setnx(key, mock_value, options)
133
- redis.has_expire?(key, options[:expire_after]).must_equal true
137
+ _(redis.has_expire?(key, options[:expire_after])).must_equal true
134
138
  end
135
139
  end
136
140
  end
@@ -2,6 +2,6 @@ require 'test_helper'
2
2
 
3
3
  describe Redis::Store::VERSION do
4
4
  it 'returns current version' do
5
- Redis::Store::VERSION.wont_equal nil
5
+ _(Redis::Store::VERSION).wont_equal nil
6
6
  end
7
7
  end
@@ -12,7 +12,7 @@ describe Redis::Store do
12
12
  end
13
13
 
14
14
  it "returns useful informations about the server" do
15
- @store.to_s.must_equal("Redis Client connected to #{@client.host}:#{@client.port} against DB #{@client.db}")
15
+ _(@store.to_s).must_equal("Redis Client connected to #{@client.host}:#{@client.port} against DB #{@client.db}")
16
16
  end
17
17
 
18
18
  it "must force reconnection" do
@@ -41,15 +41,15 @@ describe Redis::Store do
41
41
 
42
42
  # without options no ex or nx will be set
43
43
  @store.del(key)
44
- @store.set(key, mock_value, {}).must_equal 'OK'
45
- @store.set(key, mock_value, {}).must_equal 'OK'
46
- @store.ttl(key).must_equal -1
44
+ _(@store.set(key, mock_value, {})).must_equal 'OK'
45
+ _(@store.set(key, mock_value, {})).must_equal 'OK'
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)
50
- @store.set(key, mock_value, options).must_equal true
51
- @store.set(key, mock_value, options).must_equal false
52
- @store.ttl(key).must_equal 3600
50
+ _(@store.set(key, mock_value, options)).must_equal true
51
+ _(@store.set(key, mock_value, options)).must_equal false
52
+ _(@store.ttl(key)).must_equal 3600
53
53
  end
54
54
  end
55
55
  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.6.0
4
+ version: 1.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-05 00:00:00.000000000 Z
11
+ date: 2023-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -16,48 +16,48 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.2'
19
+ version: '4'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '5'
22
+ version: '6'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '2.2'
29
+ version: '4'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '5'
32
+ version: '6'
33
33
  - !ruby/object:Gem::Dependency
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
50
50
  requirements:
51
- - - "~>"
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: '1.3'
53
+ version: '0'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: '1.3'
60
+ version: '0'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: mocha
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -179,17 +179,24 @@ extensions: []
179
179
  extra_rdoc_files: []
180
180
  files:
181
181
  - ".codeclimate.yml"
182
+ - ".github/auto-assign-issues.yml"
183
+ - ".github/release.yml"
184
+ - ".github/workflows/ci.yml"
185
+ - ".github/workflows/publish.yml"
182
186
  - ".gitignore"
183
187
  - ".rubocop.yml"
184
- - ".travis.yml"
185
188
  - Appraisals
186
189
  - CHANGELOG.md
190
+ - CODEOWNERS
187
191
  - Gemfile
188
192
  - MIT-LICENSE
189
193
  - README.md
190
194
  - Rakefile
191
- - gemfiles/redis_3_x.gemfile
195
+ - gemfiles/redis_4_0_x.gemfile
196
+ - gemfiles/redis_4_1_x.gemfile
197
+ - gemfiles/redis_4_6_x.gemfile
192
198
  - gemfiles/redis_4_x.gemfile
199
+ - gemfiles/redis_5_x.gemfile
193
200
  - lib/redis-store.rb
194
201
  - lib/redis/distributed_store.rb
195
202
  - lib/redis/store.rb
@@ -230,19 +237,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
237
  - !ruby/object:Gem::Version
231
238
  version: '0'
232
239
  requirements: []
233
- rubyforge_project: redis-store
234
- rubygems_version: 2.6.14
240
+ rubygems_version: 3.3.26
235
241
  signing_key:
236
242
  specification_version: 4
237
243
  summary: Redis stores for Ruby frameworks
238
- test_files:
239
- - test/redis/distributed_store_test.rb
240
- - test/redis/store/factory_test.rb
241
- - test/redis/store/interface_test.rb
242
- - test/redis/store/namespace_test.rb
243
- - test/redis/store/redis_version_test.rb
244
- - test/redis/store/serialization_test.rb
245
- - test/redis/store/ttl_test.rb
246
- - test/redis/store/version_test.rb
247
- - test/redis/store_test.rb
248
- - test/test_helper.rb
244
+ test_files: []
data/.travis.yml DELETED
@@ -1,41 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- cache: bundler
4
- notifications:
5
- webhooks: https://www.travisbuddy.com
6
- on_success: never
7
-
8
- before_install:
9
- # Install Code Climate test reporter
10
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
11
- - chmod +x ./cc-test-reporter
12
- # 1.9.3 has Bundler 1.7.6 with the "undefined method `spec' for nil" bug
13
- - gem install bundler
14
-
15
- rvm:
16
- - 2.1
17
- - 2.2
18
- - 2.3
19
- - 2.4
20
- - ruby-head
21
- - jruby-head
22
-
23
- gemfile:
24
- - gemfiles/redis_3_x.gemfile
25
- - gemfiles/redis_4_x.gemfile
26
-
27
- before_script: ./cc-test-reporter before-build
28
-
29
- # Pipe the coverage data to Code Climate if tests pass
30
- after_script:
31
- - ./cc-test-reporter after-build --exit-code $EXIT_CODE
32
- - ./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.json
33
- - if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then ./cc-test-reporter upload-coverage; fi # Upload coverage/codeclimate.json
34
-
35
- matrix:
36
- allow_failures:
37
- - rvm: jruby-head
38
- - rvm: ruby-head
39
- exclude:
40
- - rvm: 2.1
41
- gemfile: gemfiles/redis_4_x.gemfile