redis_open3 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redis_open3/enum.rb +4 -1
- data/lib/redis_open3/version.rb +1 -1
- data/spec/lib/redis_open3/enum_spec.rb +45 -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: feae8cfda77b7f59f92f97ba7175822d6c553baa
|
4
|
+
data.tar.gz: b4235f971c1adbb9c5b1803d85e04bc2b206c6c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6681bac1bd5a1c1ce08f51c754b50635c50673347d164973e0cda0b200b8c4020bbc811bf70b730697a7cad6ba5fb52d8ec8a9fb06f4385b0ae5dd8d83aa516a
|
7
|
+
data.tar.gz: aeca2f68f2b8d472a621bcc4f1dcbef3195c1908e912eea2a817896046fd0d14095ee413b540e8851e1949d40768ce49a8e5b59a3c4977cb1847c285366f0649
|
data/lib/redis_open3/enum.rb
CHANGED
@@ -51,10 +51,13 @@ class RedisOpen3
|
|
51
51
|
|
52
52
|
def push(string)
|
53
53
|
@redis.rpush(list_name, string)
|
54
|
+
@redis.expire(list_name, @timeout + 10)
|
54
55
|
end
|
55
56
|
|
56
57
|
def pop
|
57
|
-
|
58
|
+
popped = @redis.blpop(list_name, @timeout)
|
59
|
+
@redis.expire(list_name, @timeout + 10)
|
60
|
+
if popped
|
58
61
|
popped.last
|
59
62
|
else
|
60
63
|
raise TimeoutError, "Timeout of #{@timeout.inspect} seconds expired on list_name #{list_name.inspect}."
|
data/lib/redis_open3/version.rb
CHANGED
@@ -2,7 +2,8 @@ require 'redis_open3/enum'
|
|
2
2
|
|
3
3
|
describe RedisOpen3::Enum do
|
4
4
|
let(:list_name) { 'redis_open3:redis_enum:test_list' }
|
5
|
-
let(:
|
5
|
+
let(:timeout) { 1 }
|
6
|
+
let(:enum) { RedisOpen3::Enum.new(list_name, redis: RedisConn.conn, timeout: timeout) }
|
6
7
|
let(:eof) { RedisOpen3::Enum::EOF }
|
7
8
|
|
8
9
|
after { enum.delete }
|
@@ -17,6 +18,16 @@ describe RedisOpen3::Enum do
|
|
17
18
|
}.from(nil).to('test_item')
|
18
19
|
end
|
19
20
|
end
|
21
|
+
|
22
|
+
it 'resets the ttl' do
|
23
|
+
RedisConn.with do |redis|
|
24
|
+
expect {
|
25
|
+
enum << 'test_item'
|
26
|
+
}.to change {
|
27
|
+
redis.ttl(list_name).to_i
|
28
|
+
}.from(-1).to(be > timeout)
|
29
|
+
end
|
30
|
+
end
|
20
31
|
end
|
21
32
|
|
22
33
|
describe '#close' do
|
@@ -29,6 +40,16 @@ describe RedisOpen3::Enum do
|
|
29
40
|
}.from(nil).to(eof)
|
30
41
|
end
|
31
42
|
end
|
43
|
+
|
44
|
+
it 'resets the ttl' do
|
45
|
+
RedisConn.with do |redis|
|
46
|
+
expect {
|
47
|
+
enum.close
|
48
|
+
}.to change {
|
49
|
+
redis.ttl(list_name).to_i
|
50
|
+
}.from(-1).to(be > timeout)
|
51
|
+
end
|
52
|
+
end
|
32
53
|
end
|
33
54
|
|
34
55
|
describe '#each' do
|
@@ -48,6 +69,19 @@ describe RedisOpen3::Enum do
|
|
48
69
|
found_items = enum.each.to_a
|
49
70
|
expected_items.each_with_index { |item, i| expect(found_items[i]).to eq item }
|
50
71
|
end
|
72
|
+
|
73
|
+
it 'resets the ttl' do
|
74
|
+
RedisConn.with do |redis|
|
75
|
+
redis.rpush(list_name, 'junk')
|
76
|
+
redis.rpush(list_name, eof)
|
77
|
+
redis.persist(list_name)
|
78
|
+
|
79
|
+
expect(redis.ttl(list_name)).to eq -1
|
80
|
+
enum.each do |item|
|
81
|
+
expect(redis.ttl(list_name).to_i).to be > timeout
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
51
85
|
end
|
52
86
|
|
53
87
|
describe '#delete' do
|
@@ -75,6 +109,16 @@ describe RedisOpen3::Enum do
|
|
75
109
|
}.from(nil).to(err)
|
76
110
|
end
|
77
111
|
end
|
112
|
+
|
113
|
+
it 'resets the ttl' do
|
114
|
+
RedisConn.with do |redis|
|
115
|
+
expect {
|
116
|
+
enum.fail
|
117
|
+
}.to change {
|
118
|
+
redis.ttl(list_name).to_i
|
119
|
+
}.from(-1).to(be > timeout)
|
120
|
+
end
|
121
|
+
end
|
78
122
|
end
|
79
123
|
|
80
124
|
context 'timeout' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_open3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Hartland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|