rediska 0.0.5 → 0.0.6
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.
- data/.travis.yml +0 -1
- data/Gemfile +0 -1
- data/Gemfile.lock +2 -23
- data/lib/rediska/driver.rb +21 -15
- data/lib/rediska/version.rb +1 -1
- data/rediska.gemspec +0 -2
- data/spec/spec_helper.rb +0 -2
- data/spec/support/hashes.rb +2 -2
- data/spec/support/keys.rb +29 -8
- data/spec/support/sorted_sets.rb +2 -2
- data/spec/support/strings.rb +3 -3
- metadata +2 -34
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,42 +1,25 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rediska (0.0.
|
4
|
+
rediska (0.0.6)
|
5
5
|
redis (~> 3.0.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
coderay (1.0.9)
|
11
|
-
columnize (0.3.6)
|
12
10
|
coveralls (0.7.0)
|
13
11
|
multi_json (~> 1.3)
|
14
12
|
rest-client
|
15
13
|
simplecov (>= 0.7)
|
16
14
|
term-ansicolor
|
17
15
|
thor
|
18
|
-
debugger (1.6.2)
|
19
|
-
columnize (>= 0.3.1)
|
20
|
-
debugger-linecache (~> 1.2.0)
|
21
|
-
debugger-ruby_core_source (~> 1.2.3)
|
22
|
-
debugger-linecache (1.2.0)
|
23
|
-
debugger-ruby_core_source (1.2.3)
|
24
16
|
diff-lcs (1.2.4)
|
25
17
|
json (1.8.1)
|
26
|
-
method_source (0.8.2)
|
27
18
|
mime-types (1.25)
|
28
19
|
multi_json (1.8.2)
|
29
|
-
pry (0.9.12.2)
|
30
|
-
coderay (~> 1.0.5)
|
31
|
-
method_source (~> 0.8)
|
32
|
-
slop (~> 3.4)
|
33
|
-
pry-debugger (0.2.2)
|
34
|
-
debugger (~> 1.3)
|
35
|
-
pry (~> 0.9.10)
|
36
|
-
rake (10.1.0)
|
37
20
|
rdoc (4.0.1)
|
38
21
|
json (~> 1.4)
|
39
|
-
redis (3.0.
|
22
|
+
redis (3.0.6)
|
40
23
|
rest-client (1.6.7)
|
41
24
|
mime-types (>= 1.16)
|
42
25
|
rspec (2.14.1)
|
@@ -51,7 +34,6 @@ GEM
|
|
51
34
|
multi_json (~> 1.0)
|
52
35
|
simplecov-html (~> 0.7.1)
|
53
36
|
simplecov-html (0.7.1)
|
54
|
-
slop (3.4.6)
|
55
37
|
term-ansicolor (1.2.2)
|
56
38
|
tins (~> 0.8)
|
57
39
|
thor (0.18.1)
|
@@ -62,9 +44,6 @@ PLATFORMS
|
|
62
44
|
|
63
45
|
DEPENDENCIES
|
64
46
|
coveralls
|
65
|
-
pry
|
66
|
-
pry-debugger
|
67
|
-
rake
|
68
47
|
rdoc
|
69
48
|
rediska!
|
70
49
|
rspec (~> 2.14)
|
data/lib/rediska/driver.rb
CHANGED
@@ -467,7 +467,7 @@ module Rediska
|
|
467
467
|
if data.expires.include?(key) && (ttl = data.expires[key].to_i - Time.now.to_i) > 0
|
468
468
|
ttl
|
469
469
|
else
|
470
|
-
-1
|
470
|
+
exists(key) ? -1 : -2
|
471
471
|
end
|
472
472
|
end
|
473
473
|
|
@@ -610,7 +610,10 @@ module Rediska
|
|
610
610
|
def mset(*pairs)
|
611
611
|
# Handle pairs for mapped_mset command
|
612
612
|
pairs = pairs[0] if mapped_param?(pairs)
|
613
|
-
raise_argument_error('mset') if pairs.empty? || pairs.size
|
613
|
+
raise_argument_error('mset') if pairs.empty? || pairs.size == 1
|
614
|
+
# We have to reply with a different error message here to be consistent with
|
615
|
+
# redis-rb 3.0.6 / redis-server 2.8.1.
|
616
|
+
raise_argument_error('mset', 'mset_odd') if pairs.size.odd?
|
614
617
|
|
615
618
|
pairs.each_slice(2) do |pair|
|
616
619
|
data[pair[0].to_s] = pair[1].to_s
|
@@ -655,16 +658,12 @@ module Rediska
|
|
655
658
|
|
656
659
|
def type(key)
|
657
660
|
case data[key]
|
658
|
-
when nil
|
659
|
-
|
660
|
-
when
|
661
|
-
|
662
|
-
when
|
663
|
-
|
664
|
-
when Array
|
665
|
-
'list'
|
666
|
-
when ::Set
|
667
|
-
'set'
|
661
|
+
when nil then 'none'
|
662
|
+
when String then 'string'
|
663
|
+
when ZSet then 'zset'
|
664
|
+
when Hash then 'hash'
|
665
|
+
when Array then 'list'
|
666
|
+
when ::Set then 'set'
|
668
667
|
end
|
669
668
|
end
|
670
669
|
|
@@ -824,6 +823,7 @@ module Rediska
|
|
824
823
|
end
|
825
824
|
|
826
825
|
def zrevrangebyscore(key, max, min, *opts)
|
826
|
+
opts = opts.flatten
|
827
827
|
data_type_check(key, ZSet)
|
828
828
|
return [] unless data[key]
|
829
829
|
|
@@ -872,8 +872,14 @@ module Rediska
|
|
872
872
|
end
|
873
873
|
|
874
874
|
private
|
875
|
-
def raise_argument_error command
|
876
|
-
|
875
|
+
def raise_argument_error(command, match_string = command)
|
876
|
+
error_message = if %w(hmset mset_odd).include?(match_string.downcase)
|
877
|
+
"ERR wrong number of arguments for #{command.upcase}"
|
878
|
+
else
|
879
|
+
"ERR wrong number of arguments for '#{command}' command"
|
880
|
+
end
|
881
|
+
|
882
|
+
raise Redis::CommandError, error_message
|
877
883
|
end
|
878
884
|
|
879
885
|
def raise_syntax_error
|
@@ -886,7 +892,7 @@ module Rediska
|
|
886
892
|
|
887
893
|
def data_type_check(key, klass)
|
888
894
|
if data[key] && !data[key].is_a?(klass)
|
889
|
-
raise Redis::CommandError.new('
|
895
|
+
raise Redis::CommandError.new('WRONGTYPE Operation against a key holding the wrong kind of value')
|
890
896
|
end
|
891
897
|
end
|
892
898
|
|
data/lib/rediska/version.rb
CHANGED
data/rediska.gemspec
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/support/hashes.rb
CHANGED
@@ -116,7 +116,7 @@ shared_examples 'hashes' do
|
|
116
116
|
it 'should reject the wrong number of arguments' do
|
117
117
|
expect {
|
118
118
|
subject.hmset('hash', 'foo1', 'bar1', 'foo2', 'bar2', 'foo3')
|
119
|
-
}.to raise_error(Redis::CommandError)
|
119
|
+
}.to raise_error(Redis::CommandError, 'ERR wrong number of arguments for HMSET')
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'should set multiple hash fields to multiple values' do
|
@@ -169,7 +169,7 @@ shared_examples 'hashes' do
|
|
169
169
|
it 'should reject a list of arrays that contain an invalid number of arguments' do
|
170
170
|
expect {
|
171
171
|
subject.hmset('key1', [:k1, 'val1'], [:k2, 'val2', 'bogus val'])
|
172
|
-
}.to raise_error(Redis::CommandError)
|
172
|
+
}.to raise_error(Redis::CommandError, 'ERR wrong number of arguments for HMSET')
|
173
173
|
end
|
174
174
|
|
175
175
|
it 'should convert a integer field name to string for hdel' do
|
data/spec/support/keys.rb
CHANGED
@@ -55,11 +55,11 @@ shared_examples 'keys' do
|
|
55
55
|
subject.ttl('key1').should eq(-1)
|
56
56
|
end
|
57
57
|
|
58
|
-
it 'should not have a ttl if expired' do
|
58
|
+
it 'should not have a ttl if expired (and thus key does not exist)' do
|
59
59
|
subject.set('key1', '1')
|
60
60
|
subject.expireat('key1', Time.now.to_i)
|
61
61
|
|
62
|
-
subject.ttl('key1').should eq(-
|
62
|
+
subject.ttl('key1').should eq(-2)
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'should not find a key if expired' do
|
@@ -149,8 +149,29 @@ shared_examples 'keys' do
|
|
149
149
|
it 'should determine the type stored at key' do
|
150
150
|
subject.set('key1', '1')
|
151
151
|
|
152
|
-
|
153
|
-
subject.type('key0').should
|
152
|
+
# Non-existing key.
|
153
|
+
subject.type('key0').should be == 'none'
|
154
|
+
|
155
|
+
# String.
|
156
|
+
subject.set('key1', '1')
|
157
|
+
subject.type('key1').should be == 'string'
|
158
|
+
|
159
|
+
|
160
|
+
# List.
|
161
|
+
subject.lpush('key2', '1')
|
162
|
+
subject.type('key2').should be == 'list'
|
163
|
+
|
164
|
+
# Set.
|
165
|
+
subject.sadd('key3', '1')
|
166
|
+
subject.type('key3').should be == 'set'
|
167
|
+
|
168
|
+
# Sorted Set.
|
169
|
+
subject.zadd('key4', 1.0, '1')
|
170
|
+
subject.type('key4').should be == 'zset'
|
171
|
+
|
172
|
+
# Hash.
|
173
|
+
subject.hset('key5', 'a', '1')
|
174
|
+
subject.type('key5').should be == 'hash'
|
154
175
|
end
|
155
176
|
|
156
177
|
it 'should convert the value into a string before storing' do
|
@@ -187,21 +208,21 @@ shared_examples 'keys' do
|
|
187
208
|
|
188
209
|
expect {
|
189
210
|
subject.get('key1')
|
190
|
-
}.to raise_error(Redis::CommandError, '
|
211
|
+
}.to raise_error(Redis::CommandError, 'WRONGTYPE Operation against a key holding the wrong kind of value')
|
191
212
|
|
192
213
|
expect {
|
193
214
|
subject.getset('key1', 1)
|
194
|
-
}.to raise_error(Redis::CommandError, '
|
215
|
+
}.to raise_error(Redis::CommandError, 'WRONGTYPE Operation against a key holding the wrong kind of value')
|
195
216
|
|
196
217
|
subject.hset('key2', 'one', 'two')
|
197
218
|
|
198
219
|
expect {
|
199
220
|
subject.get('key2')
|
200
|
-
}.to raise_error(Redis::CommandError, '
|
221
|
+
}.to raise_error(Redis::CommandError, 'WRONGTYPE Operation against a key holding the wrong kind of value')
|
201
222
|
|
202
223
|
expect {
|
203
224
|
subject.getset('key2', 1)
|
204
|
-
}.to raise_error(Redis::CommandError, '
|
225
|
+
}.to raise_error(Redis::CommandError, 'WRONGTYPE Operation against a key holding the wrong kind of value')
|
205
226
|
end
|
206
227
|
|
207
228
|
it 'should move a key from one database to another successfully' do
|
data/spec/support/sorted_sets.rb
CHANGED
@@ -191,10 +191,10 @@ shared_examples 'sorted sets' do
|
|
191
191
|
subject.zrevrangebyscore('key', 100, 0).should eq(['three', 'two', 'one'])
|
192
192
|
subject.zrevrangebyscore('key', 2, 1).should eq(['two', 'one'])
|
193
193
|
subject.zrevrangebyscore('key', 1, 2).should be_empty
|
194
|
-
subject.zrevrangebyscore('key', 2, 1, with_scores: true).should eq([['two', 2], ['one', 1]])
|
194
|
+
subject.zrevrangebyscore('key', 2, 1, with_scores: true).should eq([['two', 2.0], ['one', 1.0]])
|
195
195
|
subject.zrevrangebyscore('key', 100, 0, limit: [0, 1]).should eq(['three'])
|
196
196
|
subject.zrevrangebyscore('key', 100, 0, limit: [0, -1]).should eq(['three', 'two', 'one'])
|
197
|
-
subject.zrevrangebyscore('key', 100, 0, limit: [1, -1], with_scores: true).should eq([['two', 2], ['one', 1]])
|
197
|
+
subject.zrevrangebyscore('key', 100, 0, limit: [1, -1], with_scores: true).should eq([['two', 2.0], ['one', 1.0]])
|
198
198
|
end
|
199
199
|
|
200
200
|
it 'should determine the index of a member in a sorted set' do
|
data/spec/support/strings.rb
CHANGED
@@ -159,15 +159,15 @@ shared_examples 'strings' do
|
|
159
159
|
it 'should raise error if command arguments count is wrong' do
|
160
160
|
expect {
|
161
161
|
subject.mset
|
162
|
-
}.to raise_error(Redis::CommandError)
|
162
|
+
}.to raise_error(Redis::CommandError, "ERR wrong number of arguments for 'mset' command")
|
163
163
|
|
164
164
|
expect {
|
165
165
|
subject.mset(:key1)
|
166
|
-
}.to raise_error(Redis::CommandError)
|
166
|
+
}.to raise_error(Redis::CommandError, "ERR wrong number of arguments for 'mset' command")
|
167
167
|
|
168
168
|
expect {
|
169
169
|
subject.mset(:key1, 'value', :key2)
|
170
|
-
}.to raise_error(Redis::CommandError)
|
170
|
+
}.to raise_error(Redis::CommandError, 'ERR wrong number of arguments for MSET')
|
171
171
|
|
172
172
|
subject.get('key1').should be_nil
|
173
173
|
subject.get('key2').should be_nil
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rediska
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|
@@ -59,38 +59,6 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: pry
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: pry-debugger
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ! '>='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '0'
|
86
|
-
type: :development
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
94
62
|
description: ! "A light-weighted redis driver for testing, development, and minimal
|
95
63
|
environments,\n which supports various data storage strategies."
|
96
64
|
email:
|