rotary 0.1.6 → 0.1.7
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 +8 -8
- data/lib/rotary/version.rb +1 -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: 937de9bd091e3c310811ba5ca77d566f8197fce6
|
4
|
+
data.tar.gz: 0bb6b8a64a102bdf777c1c1f345e1f46e6c301d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94c47830c8ae7f204384457b6f8109a334a54738fab172f8d8cc7d33c8c0e0bf51bfd37a89d58bbfdd4ce37e3a17579a8dc126828820767577cdd1beb9ff80aa
|
7
|
+
data.tar.gz: fd5cf5e64b15afcbdf42389db23a399762002216d966ece09ee9e54eff3dd457677199f0a47b9af7ffed69a0393671959da81b91b3466bb9e241c4930dfe0475
|
data/lib/rotary/storage/redis.rb
CHANGED
@@ -60,12 +60,10 @@ module Rotary
|
|
60
60
|
|
61
61
|
# Removes sessions, where ttl is bigger than threshold n.
|
62
62
|
def clean_older_than(n)
|
63
|
-
len = @redis.llen(@pool_list)
|
64
|
-
|
65
63
|
# It doesn't have to happen atomically.
|
66
64
|
# New session will be lpush'ed, we can easily check only
|
67
65
|
# N sessions from the right.
|
68
|
-
|
66
|
+
size.times do
|
69
67
|
serialized_session = @redis.rpop(@pool_list)
|
70
68
|
|
71
69
|
# We have no sessions left. It can happen.
|
@@ -74,11 +72,13 @@ module Rotary
|
|
74
72
|
key = ttl_key(serialized_session)
|
75
73
|
ttl_marker = @redis.ttl(key)
|
76
74
|
|
77
|
-
#
|
78
|
-
|
79
|
-
|
75
|
+
# When key doesn't exist
|
76
|
+
# redis <= 2.6 returns -1
|
77
|
+
# redis >= 2.8 returns -2
|
78
|
+
no_key = [-1, -2].include?(ttl_marker)
|
79
|
+
next if no_key
|
80
80
|
|
81
|
-
old = ttl_marker < (@ttl - n)
|
81
|
+
old = @ttl ? ttl_marker < (@ttl - n) : false
|
82
82
|
if old
|
83
83
|
# delete ttl key
|
84
84
|
@redis.del(key)
|
@@ -87,7 +87,7 @@ module Rotary
|
|
87
87
|
yield(session) if block_given?
|
88
88
|
else
|
89
89
|
# push back from the left side
|
90
|
-
@redis.lpush(@pool_list,
|
90
|
+
@redis.lpush(@pool_list, serialized_session)
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
data/lib/rotary/version.rb
CHANGED
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.7
|
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-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|