redis-store 1.4.0 → 1.4.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
2
  SHA1:
3
- metadata.gz: fcf8af10e3ba000726fa40f3633c0bd725f3c1f1
4
- data.tar.gz: c51a300a95250fb34af534d1d3f427122baf919a
3
+ metadata.gz: 343594d8b51298be4a1d5c015a64d04fe1939c12
4
+ data.tar.gz: 3ee360fae5b291f77f56175cc34e18e635af655d
5
5
  SHA512:
6
- metadata.gz: f7f5e7c2b314d06103bc76a14cb203bf23815d9b98c2d828d9dad75b7fcaf59761f171daca30ca5e6d780d8bf83107fbd78a8796cdd5215fba0e5f88b8c30133
7
- data.tar.gz: e849f9d018d464eb359d0bb17c10e1adbecae028e64eb7e99b81d995373d58f25a35980513eaf9c5177e9a47fa1b426e131b59f546e5acb2e421854cee6f440c
6
+ metadata.gz: '0906711b266addefc485ddad054c70eb1d25ccfdc8162c9c9225229d1e26be1c66361ef1704a86e8e7e17419ef961c6aec3c85156275794f956921964b599c2e'
7
+ data.tar.gz: 4aa88e8de4f00b29e20dd4f93bbaf4f21a18850e6cedebfb93fcbb3b98190b2cc2fd327f4aceb8dc24c66896f66095a24706b94fec31eff078ecd6440e2a9a7c
@@ -10,7 +10,6 @@ rvm:
10
10
  - 2.2
11
11
  - 2.3.0
12
12
  - ruby-head
13
- - jruby-19mode
14
13
  - jruby-head
15
14
  bundler_args: '--path vendor/bundle'
16
15
 
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.4.1
4
+
5
+ Breaking Changes
6
+
7
+ * None
8
+
9
+ Added
10
+
11
+ * [Support for Redis client library v4](https://github.com/redis-store/redis-store/issues/277)
12
+
13
+ Fixed
14
+
15
+ * None
16
+
17
+ ## 1.4.0
18
+
19
+ Breaking Changes
20
+
21
+ * None
22
+
23
+ Added
24
+
25
+ * Pluggable backend for serializing data in/out of Redis, eventually replacing `:marshalling` in v2.
26
+
27
+ Fixed
28
+
29
+ * Conventional `Marshal.dump` usage allowing potential security vulnerability (CVE-2017-1000248)
30
+
3
31
  ## 1.3.0
4
32
 
5
33
  Breaking Changes
@@ -20,7 +20,7 @@ class Redis
20
20
  if @addresses.empty?
21
21
  @addresses << {}
22
22
  end
23
-
23
+
24
24
  if @addresses.size > 1
25
25
  ::Redis::DistributedStore.new @addresses, @options
26
26
  else
@@ -99,7 +99,6 @@ class Redis
99
99
  end
100
100
  end
101
101
  end
102
-
103
102
  end
104
103
  end
105
104
  end
@@ -43,6 +43,10 @@ class Redis
43
43
  super(*keys.map {|key| interpolate(key) }) if keys.any?
44
44
  end
45
45
 
46
+ def watch(*keys)
47
+ super(*keys.map {|key| interpolate(key) }) if keys.any?
48
+ end
49
+
46
50
  def mget(*keys)
47
51
  options = (keys.pop if keys.last.is_a? Hash) || {}
48
52
  if keys.any?
@@ -11,15 +11,15 @@ class Redis
11
11
 
12
12
  def setnx(key, value, options = nil)
13
13
  if ttl = expires_in(options)
14
- setnx_with_expire(key, value, ttl.to_i)
14
+ setnx_with_expire(key, value, ttl.to_i, options)
15
15
  else
16
16
  super(key, value)
17
17
  end
18
18
  end
19
19
 
20
20
  protected
21
- def setnx_with_expire(key, value, ttl)
22
- multi do
21
+ def setnx_with_expire(key, value, ttl, options = {})
22
+ with_multi_or_pipelined(options) do
23
23
  setnx(key, value, :raw => true)
24
24
  expire(key, ttl)
25
25
  end
@@ -32,6 +32,11 @@ class Redis
32
32
  options[:expire_after] || options[:expires_in] || options[:expire_in]
33
33
  end
34
34
  end
35
+
36
+ def with_multi_or_pipelined(options, &block)
37
+ return pipelined(&block) if options[:avoid_multi_commands]
38
+ multi(&block)
39
+ end
35
40
  end
36
41
  end
37
42
  end
@@ -1,5 +1,5 @@
1
1
  class Redis
2
2
  class Store < self
3
- VERSION = '1.4.0'
3
+ VERSION = '1.4.1'
4
4
  end
5
5
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
  s.license = 'MIT'
21
21
 
22
- s.add_dependency 'redis', '>= 2.2', '< 4'
22
+ s.add_dependency 'redis', '>= 2.2', '< 5'
23
23
 
24
24
  s.add_development_dependency 'rake', '~> 10'
25
25
  s.add_development_dependency 'bundler', '~> 1.3'
@@ -29,4 +29,4 @@ Gem::Specification.new do |s|
29
29
  s.add_development_dependency 'pry-nav', '~> 0.2.4'
30
30
  s.add_development_dependency 'pry', '~> 0.10.4'
31
31
  s.add_development_dependency 'redis-store-testing'
32
- end
32
+ end
@@ -148,7 +148,7 @@ describe "Redis::Store::Factory" do
148
148
  it "correctly uses specified ipv6 host" do
149
149
  store = Redis::Store::Factory.create "redis://[::1]:6380"
150
150
  store.to_s.must_equal("Redis Client connected to [::1]:6380 against DB 0")
151
- store.client.host.must_equal("::1")
151
+ store.instance_variable_get('@options')[:host].must_equal("::1")
152
152
  end
153
153
 
154
154
  it "instantiates Redis::DistributedStore" do
@@ -152,5 +152,10 @@ describe "Redis::Store::Namespace" do
152
152
  client.expects(:call).with([:ttl, "#{@namespace}:rabbit"]).once
153
153
  store.ttl("rabbit")
154
154
  end
155
+
156
+ it "should namespace watch" do
157
+ client.expects(:call).with([:watch,"#{@namespace}:rabbit"]).once
158
+ store.watch("rabbit")
159
+ end
155
160
  end
156
161
  end
@@ -41,6 +41,7 @@ class MockRedis
41
41
  block.call
42
42
  end
43
43
  end
44
+ alias_method :pipelined, :multi
44
45
 
45
46
  def expire(*a)
46
47
  @expires << a
@@ -94,13 +95,17 @@ describe MockTtlStore do
94
95
  end
95
96
 
96
97
  it 'must not call expire' do
97
- MockTtlStore.any_instance.expects(:expire).never
98
-
98
+ redis.expects(:expire).never
99
99
  redis.setnx(key, mock_value)
100
100
  end
101
101
  end
102
102
 
103
103
  describe 'with expiry' do
104
+ it 'uses the mutli command to chain commands' do
105
+ redis.expects(:multi)
106
+ redis.setnx(key, mock_value, options)
107
+ end
108
+
104
109
  it 'must call setnx with key and value and set raw to true' do
105
110
  redis.setnx(key, mock_value, options)
106
111
  redis.has_setnx?(key, mock_value, :raw => true).must_equal true
@@ -110,6 +115,25 @@ describe MockTtlStore do
110
115
  redis.setnx(key, mock_value, options)
111
116
  redis.has_expire?(key, options[:expire_after]).must_equal true
112
117
  end
118
+
119
+ describe 'avoiding multi commands' do
120
+ let(:options) { { :expire_after => 3600, :avoid_multi_commands => true } }
121
+
122
+ it 'uses the redis pipelined feature to chain commands' do
123
+ redis.expects(:pipelined)
124
+ redis.setnx(key, mock_value, options)
125
+ end
126
+
127
+ it 'must call setnx with key and value and set raw to true' do
128
+ redis.setnx(key, mock_value, options)
129
+ redis.has_setnx?(key, mock_value, :raw => true).must_equal true
130
+ end
131
+
132
+ it 'must call expire' do
133
+ redis.setnx(key, mock_value, options)
134
+ redis.has_expire?(key, options[:expire_after]).must_equal true
135
+ end
136
+ end
113
137
  end
114
138
  end
115
139
  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.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-25 00:00:00.000000000 Z
11
+ date: 2017-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '2.2'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '4'
22
+ version: '5'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '2.2'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '4'
32
+ version: '5'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rake
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -152,7 +152,7 @@ extra_rdoc_files: []
152
152
  files:
153
153
  - ".gitignore"
154
154
  - ".travis.yml"
155
- - CHANGELOG
155
+ - CHANGELOG.md
156
156
  - Gemfile
157
157
  - MIT-LICENSE
158
158
  - README.md