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 +4 -4
- data/lib/rotary/storage/redis.rb +6 -3
- data/lib/rotary/version.rb +1 -1
- data/lib/rotary.rb +2 -2
- 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: d91a035b7bc8d12853f4f372312d47a79ee2008f
|
4
|
+
data.tar.gz: 0816ed9b7d5e25759a9d672296db5647e5baa528
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 963995e2f76b2cd92547b565427b055b950bf9932ee9c332b7a34cb4207af22888171527cdc8dc9c26bf6a0ae03ad0dea927572c0c0edcb203f36709de77c963
|
7
|
+
data.tar.gz: 548523678285d0d620d83d51145c2bd09b31a3aec99c0c4fd21ed1c78f67b040cd0745c98d63d9e478b308ac362649d7a68695e6a9ff125392698753771afeff
|
data/lib/rotary/storage/redis.rb
CHANGED
@@ -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
|
-
|
69
|
+
serialized_session = @redis.rpop(@pool_list)
|
70
70
|
|
71
71
|
# We have no sessions left. It can happen.
|
72
|
-
break unless
|
72
|
+
break unless serialized_session
|
73
73
|
|
74
|
-
key = ttl_key(
|
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)
|
data/lib/rotary/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2014-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|