rotary 0.1.5 → 0.1.6

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: 0cdba58ff533cd3db29aea9f62ed8edc8bc12552
4
- data.tar.gz: ca8b3103ba9c30a9e79863f9747d550e1aacd30e
3
+ metadata.gz: d91a035b7bc8d12853f4f372312d47a79ee2008f
4
+ data.tar.gz: 0816ed9b7d5e25759a9d672296db5647e5baa528
5
5
  SHA512:
6
- metadata.gz: 26852888142ea6dc2639bcd3803c38e6a5a4f92023a77aaab5d57ecfa477eb62ef2e879976bb6b9e6e5118c97f8b5805514dee789b17228aba650660d4918333
7
- data.tar.gz: c21725994e493e55bc4a3a66a20e1fd19ae513e3fd0fddf0ac85e66d688a1cc9c045045cdad0b1c9c8e405ad48d8924f7979c081c0b3a3da8c9a9a95699922ce
6
+ metadata.gz: 963995e2f76b2cd92547b565427b055b950bf9932ee9c332b7a34cb4207af22888171527cdc8dc9c26bf6a0ae03ad0dea927572c0c0edcb203f36709de77c963
7
+ data.tar.gz: 548523678285d0d620d83d51145c2bd09b31a3aec99c0c4fd21ed1c78f67b040cd0745c98d63d9e478b308ac362649d7a68695e6a9ff125392698753771afeff
@@ -66,12 +66,12 @@ module Rotary
66
66
  # New session will be lpush'ed, we can easily check only
67
67
  # N sessions from the right.
68
68
  len.times do
69
- session = @redis.rpop(@pool_list)
69
+ serialized_session = @redis.rpop(@pool_list)
70
70
 
71
71
  # We have no sessions left. It can happen.
72
- break unless session
72
+ break unless serialized_session
73
73
 
74
- key = ttl_key(session)
74
+ key = ttl_key(serialized_session)
75
75
  ttl_marker = @redis.ttl(key)
76
76
 
77
77
  # redis.rb returns -2 when key doesn't exist
@@ -82,6 +82,9 @@ module Rotary
82
82
  if old
83
83
  # delete ttl key
84
84
  @redis.del(key)
85
+ # and execute the block with session as arg
86
+ session = @serializer.load(serialized_session)
87
+ yield(session) if block_given?
85
88
  else
86
89
  # push back from the left side
87
90
  @redis.lpush(@pool_list, session)
@@ -1,4 +1,4 @@
1
1
  module Rotary
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.6'
3
3
  end
4
4
 
data/lib/rotary.rb CHANGED
@@ -66,9 +66,9 @@ module Rotary
66
66
 
67
67
  # Removes all elements from pool, which means specified by block
68
68
  # argument criteria.
69
- def clean_older_than(n)
69
+ def clean_older_than(n, &block)
70
70
  if @storage.respond_to?(:clean_older_than)
71
- @storage.clean_older_than(n)
71
+ @storage.clean_older_than(n, &block)
72
72
  else
73
73
  fail "#{@storage.class}#clean_where not implemented"
74
74
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rotary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Redozubov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-14 00:00:00.000000000 Z
11
+ date: 2014-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake