rediska 0.1.0 → 0.1.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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rediska/driver.rb +8 -8
- data/lib/rediska/version.rb +1 -1
- data/spec/support/keys.rb +9 -0
- data/spec/support/lists.rb +1 -1
- data/spec/support/transactions.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd18585f05fa32a32467fc94d32a86721f605229
|
4
|
+
data.tar.gz: 33abc1203b205f9a67020ce205223c642c054d4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c6bcc3c79b86e2a5df2686e4b3a57e6c9093384f24bc6282aa18d8fffe842523f1b29609281e80b05ff2b37240d49e147b9e06dbddfd18b26e9e7063a56c585
|
7
|
+
data.tar.gz: fd8b78d827d350b5c63c0b6c49a5087fed940bd467e629870bf601ab8a49e428f44ce19f5d9902ce3514c512824454e3e264ca7dba24b73cb61265af8c549a34
|
data/Gemfile.lock
CHANGED
data/lib/rediska/driver.rb
CHANGED
@@ -197,14 +197,14 @@ module Rediska
|
|
197
197
|
data_type_check(key, Array)
|
198
198
|
return unless data[key]
|
199
199
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
data[key]
|
205
|
-
else
|
200
|
+
# Example: we have a list of 3 elements and we give it a ltrim list, -5, -1. This means it
|
201
|
+
# should trim to a max of 5. Since 3 < 5 we should not touch the list. This is consistent
|
202
|
+
# with behavior of real Redis's ltrim with a negative start argument.
|
203
|
+
unless start < 0 && data[key].count < start.abs
|
206
204
|
data[key] = data[key][start..stop]
|
207
205
|
end
|
206
|
+
|
207
|
+
'OK'
|
208
208
|
end
|
209
209
|
|
210
210
|
def lindex(key, index)
|
@@ -441,9 +441,9 @@ module Rediska
|
|
441
441
|
end
|
442
442
|
|
443
443
|
def expire(key, ttl)
|
444
|
-
return unless data[key]
|
444
|
+
return 0 unless data[key]
|
445
445
|
data.expires[key] = Time.now + ttl
|
446
|
-
|
446
|
+
1
|
447
447
|
end
|
448
448
|
|
449
449
|
def ttl(key)
|
data/lib/rediska/version.rb
CHANGED
data/spec/support/keys.rb
CHANGED
@@ -26,6 +26,15 @@ shared_examples 'keys' do
|
|
26
26
|
}.to raise_error(Redis::CommandError)
|
27
27
|
end
|
28
28
|
|
29
|
+
it 'should return true when setting expires on keys that exist' do
|
30
|
+
subject.set('key1', '1')
|
31
|
+
expect(subject.expire('key1', 1)).to be_truthy
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should return false when attempting to set expires on a key that does not exist' do
|
35
|
+
expect(subject.expire('key1', 1)).to be_falsey
|
36
|
+
end
|
37
|
+
|
29
38
|
it 'should determine if a key exists' do
|
30
39
|
subject.set('key1', '1')
|
31
40
|
|
data/spec/support/lists.rb
CHANGED
@@ -117,7 +117,7 @@ shared_examples 'lists' do
|
|
117
117
|
subject.rpush('key1', 'two')
|
118
118
|
subject.rpush('key1', 'three')
|
119
119
|
|
120
|
-
subject.ltrim('key1', 1, -1)
|
120
|
+
expect(subject.ltrim('key1', 1, -1)).to eq('OK')
|
121
121
|
expect(subject.lrange('key1', 0, -1)).to eq(['two', 'three'])
|
122
122
|
end
|
123
123
|
|
@@ -13,10 +13,11 @@ shared_examples 'transactions' do
|
|
13
13
|
transaction = subject.multi do |multi|
|
14
14
|
multi.set('key1', '1')
|
15
15
|
multi.set('key2', '2')
|
16
|
+
multi.expire('key1', 123)
|
16
17
|
multi.mget('key1', 'key2')
|
17
18
|
end
|
18
19
|
|
19
|
-
expect(transaction).to eq(['OK', 'OK', ['1', '2']])
|
20
|
+
expect(transaction).to eq(['OK', 'OK', true, ['1', '2']])
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rediska
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonid Beder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|