redis_open3 0.0.2 → 0.0.3

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: 394d841ea55842e0efe813e5e2734f27d852cd20
4
- data.tar.gz: 812e91f841ba305844b47091dbea610200f4c905
3
+ metadata.gz: feae8cfda77b7f59f92f97ba7175822d6c553baa
4
+ data.tar.gz: b4235f971c1adbb9c5b1803d85e04bc2b206c6c9
5
5
  SHA512:
6
- metadata.gz: 8d56133410c8fc67db16af3cc23918dccab6ef0f352e9b7c5c1183247e496e3f86a05b2e0649a0ff336c0ed677554085e2ec07e02d11100060e93bb3bdaa56f7
7
- data.tar.gz: 42894d54ed96ebe807e13323f0cad450a9362db8f6c779432fcd7f16ae6eebee01a25531cba0432f93bc7a1e3659695c7741c64a023f03483971f4c8bfe5ee89
6
+ metadata.gz: 6681bac1bd5a1c1ce08f51c754b50635c50673347d164973e0cda0b200b8c4020bbc811bf70b730697a7cad6ba5fb52d8ec8a9fb06f4385b0ae5dd8d83aa516a
7
+ data.tar.gz: aeca2f68f2b8d472a621bcc4f1dcbef3195c1908e912eea2a817896046fd0d14095ee413b540e8851e1949d40768ce49a8e5b59a3c4977cb1847c285366f0649
@@ -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
- if popped = @redis.blpop(list_name, @timeout)
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}."
@@ -1,3 +1,3 @@
1
1
  class RedisOpen3
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -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(:enum) { RedisOpen3::Enum.new(list_name, redis: RedisConn.conn, timeout: 1) }
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.2
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-08-26 00:00:00.000000000 Z
11
+ date: 2014-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler