redis-store 1.1.0.rc → 1.1.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of redis-store might be problematic. Click here for more details.
- data/Gemfile +3 -1
- data/Rakefile +0 -6
- data/lib/redis/store/ttl.rb +4 -4
- data/lib/redis/store/version.rb +1 -1
- data/test/redis/store/interface_test.rb +1 -1
- data/test/redis/store/ttl_test.rb +107 -0
- data/test/redis/store/version_test.rb +3 -3
- data/test/redis/store_test.rb +29 -1
- metadata +67 -122
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/lib/redis/store/ttl.rb
CHANGED
@@ -3,7 +3,7 @@ class Redis
|
|
3
3
|
module Ttl
|
4
4
|
def set(key, value, options = nil)
|
5
5
|
if ttl = expires_in(options)
|
6
|
-
setex(key, ttl, value)
|
6
|
+
setex(key, ttl.to_i, value, :raw => true)
|
7
7
|
else
|
8
8
|
super(key, value)
|
9
9
|
end
|
@@ -11,7 +11,7 @@ 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)
|
14
|
+
setnx_with_expire(key, value, ttl.to_i)
|
15
15
|
else
|
16
16
|
super(key, value)
|
17
17
|
end
|
@@ -20,8 +20,8 @@ class Redis
|
|
20
20
|
protected
|
21
21
|
def setnx_with_expire(key, value, ttl)
|
22
22
|
multi do
|
23
|
-
setnx(key, value)
|
24
|
-
expire(key,
|
23
|
+
setnx(key, value, :raw => true)
|
24
|
+
expire(key, ttl)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
data/lib/redis/store/version.rb
CHANGED
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class MockRedis
|
4
|
+
def initialize
|
5
|
+
@sets = []
|
6
|
+
@setexes = []
|
7
|
+
@setnxes = []
|
8
|
+
@expires = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def set(*a)
|
12
|
+
@sets << a
|
13
|
+
end
|
14
|
+
|
15
|
+
def has_set?(*a)
|
16
|
+
@sets.include?(a)
|
17
|
+
end
|
18
|
+
|
19
|
+
def setex(*a)
|
20
|
+
@setexes << a
|
21
|
+
end
|
22
|
+
|
23
|
+
def has_setex?(*a)
|
24
|
+
@setexes.include?(a)
|
25
|
+
end
|
26
|
+
|
27
|
+
def setnx(*a)
|
28
|
+
@setnxes << a
|
29
|
+
end
|
30
|
+
|
31
|
+
def has_setnx?(*a)
|
32
|
+
@setnxes.include?(a)
|
33
|
+
end
|
34
|
+
|
35
|
+
def multi(&block)
|
36
|
+
instance_eval do
|
37
|
+
def setnx(*a)
|
38
|
+
@setnxes << a
|
39
|
+
end
|
40
|
+
|
41
|
+
block.call
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def expire(*a)
|
46
|
+
@expires << a
|
47
|
+
end
|
48
|
+
|
49
|
+
def has_expire?(*a)
|
50
|
+
@expires.include?(a)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
class MockTtlStore < MockRedis
|
56
|
+
include Redis::Store::Ttl
|
57
|
+
end
|
58
|
+
|
59
|
+
describe MockTtlStore do
|
60
|
+
let(:key) { 'hello' }
|
61
|
+
let(:value) { 'value' }
|
62
|
+
let(:options) { { :expire_after => 3600 } }
|
63
|
+
let(:redis) { MockTtlStore.new }
|
64
|
+
|
65
|
+
describe '#set' do
|
66
|
+
describe 'without options' do
|
67
|
+
it 'must call super with key and value' do
|
68
|
+
redis.set(key, value)
|
69
|
+
redis.has_set?(key, value).must_equal true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe 'with options' do
|
74
|
+
it 'must call setex with proper expiry and set raw to true' do
|
75
|
+
redis.set(key, value, options)
|
76
|
+
redis.has_setex?(key, options[:expire_after], value, :raw => true).must_equal true
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#setnx' do
|
82
|
+
describe 'without expiry' do
|
83
|
+
it 'must call super with key and value' do
|
84
|
+
redis.setnx(key, value)
|
85
|
+
redis.has_setnx?(key, value)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'must not call expire' do
|
89
|
+
MockTtlStore.any_instance.expects(:expire).never
|
90
|
+
|
91
|
+
redis.setnx(key, value)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe 'with expiry' do
|
96
|
+
it 'must call setnx with key and value and set raw to true' do
|
97
|
+
redis.setnx(key, value, options)
|
98
|
+
redis.has_setnx?(key, value, :raw => true).must_equal true
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'must call expire' do
|
102
|
+
redis.setnx(key, value, options)
|
103
|
+
redis.has_expire?(key, options[:expire_after]).must_equal true
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
data/test/redis/store_test.rb
CHANGED
@@ -14,4 +14,32 @@ describe Redis::Store do
|
|
14
14
|
@client.expects(:reconnect)
|
15
15
|
@store.reconnect
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
|
+
describe '#set' do
|
19
|
+
describe 'with expiry' do
|
20
|
+
let(:key) { 'key' }
|
21
|
+
let(:value) { 'value' }
|
22
|
+
let(:options) { { :expire_after => 3600 } }
|
23
|
+
|
24
|
+
it 'must not double marshall' do
|
25
|
+
Marshal.expects(:dump).once
|
26
|
+
|
27
|
+
@store.set(key, value, options)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#setnx' do
|
33
|
+
describe 'with expiry' do
|
34
|
+
let(:key) { 'key' }
|
35
|
+
let(:value) { 'value' }
|
36
|
+
let(:options) { { :expire_after => 3600 } }
|
37
|
+
|
38
|
+
it 'must not double marshall' do
|
39
|
+
Marshal.expects(:dump).once
|
40
|
+
|
41
|
+
@store.setnx(key, value, options)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -1,146 +1,101 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-store
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0.rc2
|
5
5
|
prerelease: 6
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
- 0
|
10
|
-
- rc
|
11
|
-
version: 1.1.0.rc
|
12
6
|
platform: ruby
|
13
|
-
authors:
|
7
|
+
authors:
|
14
8
|
- Luca Guidi
|
15
9
|
autorequire:
|
16
10
|
bindir: bin
|
17
11
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-02-03 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: redis
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70182807299300 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
18
|
+
requirements:
|
27
19
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 7
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 2
|
33
|
-
- 0
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 2.2.0
|
35
22
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: rake
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: *70182807299300
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
requirement: &70182807298160 !ruby/object:Gem::Requirement
|
41
28
|
none: false
|
42
|
-
requirements:
|
29
|
+
requirements:
|
43
30
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 11
|
46
|
-
segments:
|
47
|
-
- 0
|
48
|
-
- 9
|
49
|
-
- 2
|
50
|
-
- 2
|
31
|
+
- !ruby/object:Gem::Version
|
51
32
|
version: 0.9.2.2
|
52
33
|
type: :development
|
53
|
-
version_requirements: *id002
|
54
|
-
- !ruby/object:Gem::Dependency
|
55
|
-
name: bundler
|
56
34
|
prerelease: false
|
57
|
-
|
35
|
+
version_requirements: *70182807298160
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: bundler
|
38
|
+
requirement: &70182807297380 !ruby/object:Gem::Requirement
|
58
39
|
none: false
|
59
|
-
requirements:
|
40
|
+
requirements:
|
60
41
|
- - ~>
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
hash: 7712070
|
63
|
-
segments:
|
64
|
-
- 1
|
65
|
-
- 1
|
66
|
-
- rc
|
42
|
+
- !ruby/object:Gem::Version
|
67
43
|
version: 1.1.rc
|
68
44
|
type: :development
|
69
|
-
version_requirements: *id003
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: mocha
|
72
45
|
prerelease: false
|
73
|
-
|
46
|
+
version_requirements: *70182807297380
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: mocha
|
49
|
+
requirement: &70182807296420 !ruby/object:Gem::Requirement
|
74
50
|
none: false
|
75
|
-
requirements:
|
51
|
+
requirements:
|
76
52
|
- - ~>
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
hash: 55
|
79
|
-
segments:
|
80
|
-
- 0
|
81
|
-
- 10
|
82
|
-
- 0
|
53
|
+
- !ruby/object:Gem::Version
|
83
54
|
version: 0.10.0
|
84
55
|
type: :development
|
85
|
-
version_requirements: *id004
|
86
|
-
- !ruby/object:Gem::Dependency
|
87
|
-
name: minitest
|
88
56
|
prerelease: false
|
89
|
-
|
57
|
+
version_requirements: *70182807296420
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: minitest
|
60
|
+
requirement: &70182807295000 !ruby/object:Gem::Requirement
|
90
61
|
none: false
|
91
|
-
requirements:
|
62
|
+
requirements:
|
92
63
|
- - ~>
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
hash: 47
|
95
|
-
segments:
|
96
|
-
- 2
|
97
|
-
- 8
|
98
|
-
- 0
|
64
|
+
- !ruby/object:Gem::Version
|
99
65
|
version: 2.8.0
|
100
66
|
type: :development
|
101
|
-
version_requirements: *id005
|
102
|
-
- !ruby/object:Gem::Dependency
|
103
|
-
name: purdytest
|
104
67
|
prerelease: false
|
105
|
-
|
68
|
+
version_requirements: *70182807295000
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: purdytest
|
71
|
+
requirement: &70182807294440 !ruby/object:Gem::Requirement
|
106
72
|
none: false
|
107
|
-
requirements:
|
73
|
+
requirements:
|
108
74
|
- - ~>
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
hash: 23
|
111
|
-
segments:
|
112
|
-
- 1
|
113
|
-
- 0
|
114
|
-
- 0
|
75
|
+
- !ruby/object:Gem::Version
|
115
76
|
version: 1.0.0
|
116
77
|
type: :development
|
117
|
-
version_requirements: *id006
|
118
|
-
- !ruby/object:Gem::Dependency
|
119
|
-
name: git
|
120
78
|
prerelease: false
|
121
|
-
|
79
|
+
version_requirements: *70182807294440
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: git
|
82
|
+
requirement: &70182807293680 !ruby/object:Gem::Requirement
|
122
83
|
none: false
|
123
|
-
requirements:
|
84
|
+
requirements:
|
124
85
|
- - ~>
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
hash: 21
|
127
|
-
segments:
|
128
|
-
- 1
|
129
|
-
- 2
|
130
|
-
- 5
|
86
|
+
- !ruby/object:Gem::Version
|
131
87
|
version: 1.2.5
|
132
88
|
type: :development
|
133
|
-
|
134
|
-
|
135
|
-
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70182807293680
|
91
|
+
description: Namespaced Rack::Session, Rack::Cache, I18n and cache Redis stores for
|
92
|
+
Ruby web frameworks.
|
93
|
+
email:
|
136
94
|
- guidi.luca@gmail.com
|
137
95
|
executables: []
|
138
|
-
|
139
96
|
extensions: []
|
140
|
-
|
141
97
|
extra_rdoc_files: []
|
142
|
-
|
143
|
-
files:
|
98
|
+
files:
|
144
99
|
- Gemfile
|
145
100
|
- MIT-LICENSE
|
146
101
|
- README.md
|
@@ -164,45 +119,35 @@ files:
|
|
164
119
|
- test/redis/store/interface_test.rb
|
165
120
|
- test/redis/store/marshalling_test.rb
|
166
121
|
- test/redis/store/namespace_test.rb
|
122
|
+
- test/redis/store/ttl_test.rb
|
167
123
|
- test/redis/store/version_test.rb
|
168
124
|
- test/redis/store_test.rb
|
169
125
|
- test/test_helper.rb
|
170
|
-
homepage:
|
126
|
+
homepage: ''
|
171
127
|
licenses: []
|
172
|
-
|
173
128
|
post_install_message:
|
174
129
|
rdoc_options: []
|
175
|
-
|
176
|
-
require_paths:
|
130
|
+
require_paths:
|
177
131
|
- lib
|
178
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
179
133
|
none: false
|
180
|
-
requirements:
|
181
|
-
- -
|
182
|
-
- !ruby/object:Gem::Version
|
183
|
-
|
184
|
-
|
185
|
-
- 0
|
186
|
-
version: "0"
|
187
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ! '>='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
139
|
none: false
|
189
|
-
requirements:
|
190
|
-
- -
|
191
|
-
- !ruby/object:Gem::Version
|
192
|
-
hash: 25
|
193
|
-
segments:
|
194
|
-
- 1
|
195
|
-
- 3
|
196
|
-
- 1
|
140
|
+
requirements:
|
141
|
+
- - ! '>'
|
142
|
+
- !ruby/object:Gem::Version
|
197
143
|
version: 1.3.1
|
198
144
|
requirements: []
|
199
|
-
|
200
145
|
rubyforge_project: redis-store
|
201
|
-
rubygems_version: 1.8.
|
146
|
+
rubygems_version: 1.8.15
|
202
147
|
signing_key:
|
203
148
|
specification_version: 3
|
204
149
|
summary: Redis stores for Ruby frameworks
|
205
|
-
test_files:
|
150
|
+
test_files:
|
206
151
|
- test/config/node-one.conf
|
207
152
|
- test/config/node-two.conf
|
208
153
|
- test/config/redis.conf
|
@@ -211,7 +156,7 @@ test_files:
|
|
211
156
|
- test/redis/store/interface_test.rb
|
212
157
|
- test/redis/store/marshalling_test.rb
|
213
158
|
- test/redis/store/namespace_test.rb
|
159
|
+
- test/redis/store/ttl_test.rb
|
214
160
|
- test/redis/store/version_test.rb
|
215
161
|
- test/redis/store_test.rb
|
216
162
|
- test/test_helper.rb
|
217
|
-
has_rdoc:
|