resque-waiting-room 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9058938da957ee322a1422f2564ada3b40c9b8cd
4
- data.tar.gz: c12c80cb78497fe63b84adb9c4763a693d12299c
3
+ metadata.gz: fc9d18de0b400796244ec7bbcd217f6863e0d7f0
4
+ data.tar.gz: 6a0aea7bfb129b4727b9f7fd6a2b3117d77418c7
5
5
  SHA512:
6
- metadata.gz: f0bb708ab5a6dc14381f3d77aa9c0023cd86d3485212fb6df8fa01fb02e896ee2b919b40cd03e4cec9a6e01b3c3715045a7eb79584db0a7e000dd7db2a33de92
7
- data.tar.gz: 373883a28538dfc7141000109bb3fb9453cce8907aafac166ccd723b095d84390620d5b2bc7cb5209558c9ba87b9f443356bfcdbd5e7289f05f7e4982826b2f8
6
+ metadata.gz: a2c8d82aba863078f20afdd7360bd43d47487975cd40d4a638db36defca78f710690331c0a5947d6365adcf1a56beaa90868aacead0c870aafcfc63eea8523cf
7
+ data.tar.gz: 69c19f6be8c9f303e5e6243721691b55d0fb347b3785c18a58bc6ae6d6130b4a7ad741de861e838b98282c9625118b3c17ff6076ce7491d7e53933517f7bd3be
@@ -1 +1 @@
1
- 2.1.3
1
+ 2.1.4
@@ -56,6 +56,10 @@ We include a matcher
56
56
  end
57
57
  end
58
58
 
59
+ Run tests with the following command
60
+
61
+ bundle exec rake
62
+
59
63
  ## Contributing
60
64
 
61
65
  1. Fork it
@@ -68,7 +72,8 @@ We include a matcher
68
72
 
69
73
  - Thomas Devol [@socialchorus](https://github.com/socialchorus) for adding the RSpec matcher
70
74
  - Max Dunn [@maxdunn210](https://github.com/maxdunn210) for making me switch Resque 2 specific code in it's own branch
71
- - Jeff Durand [@johnnyiller](https://github.com/johnnyiller) for the update of has_remaining_performs_key using the latest form set
75
+ - Jeff Durand [@johnnyiller](https://github.com/johnnyiller) for the update of has_remaining_performs_key using the latest form set and the fix for a rare ttl bug
76
+ - Tatsuya Takamura [@ttakamura](https://github.com/ttakamura) for raising the issue on the rare ttl bug
72
77
 
73
78
  [rq]: http://github.com/resque/resque
74
79
 
@@ -1,7 +1,7 @@
1
1
  module Resque
2
2
  module Plugins
3
3
  module WaitingRoom
4
- VERSION = '0.2.2'
4
+ VERSION = '0.2.3'
5
5
  end
6
6
  end
7
7
  end
@@ -26,16 +26,23 @@ module Resque
26
26
  end
27
27
 
28
28
  def remaining_performs_key?(key)
29
+ # if true then we will only set a key if it doesn't exist
30
+ # if false then we will set the key regardless. If we have
31
+ # a negative number then redis either doesn't know about the key
32
+ # or it doesn't have a ttl, either way we want to create a new key
33
+ # with a new ttl.
34
+ nx = Resque.redis.ttl(key).to_i > 0
35
+
29
36
  # Redis SET: with the ex and nx option sets the keys if it doesn't exist,
30
37
  # returns true if key was created redis => 2.6 required
31
- new_key = Resque.redis.set(key, @max_performs - 1, ex: @period, nx: true)
32
- return !new_key
38
+ # http://redis.io/commands/SET
39
+ !Resque.redis.set(key, @max_performs - 1, ex: @period, nx: nx)
33
40
  end
34
41
 
35
42
  def repush(*args)
36
43
  key = waiting_room_redis_key
37
44
  value = Resque.redis.get(key)
38
- no_performs_left = value && value != "" && value.to_i <= 0
45
+ no_performs_left = value && value != '' && value.to_i <= 0
39
46
  Resque.push 'waiting_room', class: self.to_s, args: args if no_performs_left
40
47
 
41
48
  return no_performs_left
@@ -72,21 +72,18 @@ describe Resque::Plugins::WaitingRoom do
72
72
 
73
73
  it 'should set a redis key' do
74
74
  expect(Resque.redis).to receive(:set)
75
- .with(@key, @max, ex: @period, nx: true)
75
+ .with(@key, @max, ex: @period, nx: false)
76
76
  DummyJob.remaining_performs_key?(DummyJob.waiting_room_redis_key)
77
77
  end
78
78
 
79
79
  it 'should expire the redis key' do
80
80
  expect(Resque.redis).to receive(:set)
81
- .with(@key, @max, ex: @period, nx: true)
81
+ .with(@key, @max, ex: @period, nx: false)
82
82
  .and_return(true)
83
83
  DummyJob.remaining_performs_key?(DummyJob.waiting_room_redis_key)
84
84
  end
85
85
 
86
86
  it 'should not re-expire the redis key if it is already created' do
87
- expect(Resque.redis).to receive(:set)
88
- .with(@key, @max, ex: @period, nx: true)
89
- .and_return(true)
90
87
  DummyJob.remaining_performs_key?(DummyJob.waiting_room_redis_key)
91
88
  expect(Resque.redis).to receive(:set)
92
89
  .with(@key, @max, ex: @period, nx: true)
@@ -96,7 +93,7 @@ describe Resque::Plugins::WaitingRoom do
96
93
 
97
94
  it 'should return false if the key is new' do
98
95
  expect(Resque.redis).to receive(:set)
99
- .with(@key, @max, ex: @period, nx: true)
96
+ .with(@key, @max, ex: @period, nx: false)
100
97
  .and_return(true)
101
98
  expect(DummyJob.remaining_performs_key?(DummyJob.waiting_room_redis_key))
102
99
  .to eq(false)
@@ -104,7 +101,7 @@ describe Resque::Plugins::WaitingRoom do
104
101
 
105
102
  it 'should return true if the key was already created' do
106
103
  expect(Resque.redis).to receive(:set)
107
- .with(@key, @max, ex: @period, nx: true)
104
+ .with(@key, @max, ex: @period, nx: false)
108
105
  .and_return(false)
109
106
  expect(DummyJob.remaining_performs_key?(DummyJob.waiting_room_redis_key))
110
107
  .to eq(true)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-waiting-room
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Blanchard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-29 00:00:00.000000000 Z
11
+ date: 2014-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake