cache_store_redis 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cache_store_redis/redis_connection_pool.rb +8 -18
- data/lib/cache_store_redis/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ac7810373ca95d92bcde9c745ac1bbef9851800ba4031f37b5565144a27e84e
|
4
|
+
data.tar.gz: 5fa2928508a259ddb26c53cd8913f519238ec1b53d66478c4849e6e69375fe94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95c5a67dd789d509f79ed5f8c22da224b817da063051bb5cbdfb713874c53837fc501fea27221c6bff1da52393023a5c47a1aeefa82ea76fd1a0c219c508a6f9
|
7
|
+
data.tar.gz: 89e660289c2f6412858bcadd35b89410ccba1c5d85aea45740024a5015c6f14734d3d48d67723202ce9b05375f577d3e95d0c6fd71cdd0593fa6a5425ca67610
|
@@ -12,29 +12,23 @@ class RedisConnectionPool
|
|
12
12
|
loop do
|
13
13
|
sleep(1)
|
14
14
|
@mutex.synchronize do
|
15
|
-
connections.select
|
16
|
-
con.close
|
17
|
-
end
|
15
|
+
connections.select(&:expired?).each(&:close)
|
18
16
|
end
|
19
17
|
end
|
20
18
|
end
|
21
19
|
end
|
22
20
|
|
23
21
|
# This method is called to get the namespace for redis keys.
|
24
|
-
|
25
|
-
@namespace
|
26
|
-
end
|
22
|
+
attr_reader :namespace
|
27
23
|
|
28
24
|
# This method is called to get the idle connection queue for this pool.
|
29
|
-
|
30
|
-
@queue
|
31
|
-
end
|
25
|
+
attr_reader :queue
|
32
26
|
|
33
27
|
# This method is called to fetch a connection from the queue or create a new connection if no idle connections
|
34
28
|
# are available.
|
35
29
|
def fetch_connection
|
36
30
|
queue.pop(true)
|
37
|
-
rescue
|
31
|
+
rescue StandardError
|
38
32
|
RedisConnection.new(config)
|
39
33
|
end
|
40
34
|
|
@@ -51,9 +45,7 @@ class RedisConnectionPool
|
|
51
45
|
|
52
46
|
# This method is called to checkin a connection to the pool after use.
|
53
47
|
def check_in(connection)
|
54
|
-
if connection.expired?
|
55
|
-
connection.close
|
56
|
-
end
|
48
|
+
connection.close if connection.expired?
|
57
49
|
@mutex.synchronize do
|
58
50
|
connections.push(connection)
|
59
51
|
queue.push(connection)
|
@@ -63,15 +55,13 @@ class RedisConnectionPool
|
|
63
55
|
# This method is called to use a connection from this pool.
|
64
56
|
def with_connection
|
65
57
|
connection = check_out
|
66
|
-
|
58
|
+
yield connection.client
|
67
59
|
ensure
|
68
|
-
check_in(connection)
|
60
|
+
check_in(connection) if connection
|
69
61
|
end
|
70
62
|
|
71
63
|
# This method is called to get an array of idle connections in this pool.
|
72
|
-
|
73
|
-
@connections
|
74
|
-
end
|
64
|
+
attr_reader :connections
|
75
65
|
|
76
66
|
def shutdown
|
77
67
|
connections.each do |con|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cache_store_redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vaughanbrittonsage
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|