cache_store_redis 1.1.0 → 2.0.0
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
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5bb583829e24ed293d2837d63176cd5721cf33891196762f790297781c56e89e
|
4
|
+
data.tar.gz: bd9fad442f4c769a3fecfb15708f26a42e2b9d1df6da2fe84db08cf3080ddfcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d4af265afe33f984b2995ff63909da9b6469a209bdd681b7797c79bfa007b9b1bdcb0f05ff859f8cf64e53a1973b5281eee573f224f819313efde131d72c91f
|
7
|
+
data.tar.gz: df1267a5783d9e47f6d042eb4914a0f717f3dd3b9834b7ac4b8907f9d6ba504ceaed43ae24ed1521c0bdb644ace8f1b46c1afd1509c92c8daa5531447db86f7e
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'logger'
|
2
|
-
|
3
1
|
# This class is used to define a redis cache store that logs failures as warnings but does not raise errors for
|
4
2
|
# cache connections
|
5
3
|
class OptionalRedisCacheStore
|
@@ -7,7 +5,7 @@ class OptionalRedisCacheStore
|
|
7
5
|
@cache_store = RedisCacheStore.new(namespace, config)
|
8
6
|
@logger = logger || Logger.new(STDOUT)
|
9
7
|
end
|
10
|
-
|
8
|
+
|
11
9
|
def redis_store
|
12
10
|
@cache_store
|
13
11
|
end
|
@@ -39,10 +37,7 @@ class OptionalRedisCacheStore
|
|
39
37
|
def optional_get(key, expires_in = 0)
|
40
38
|
redis_store.get(key, expires_in)
|
41
39
|
rescue => e
|
42
|
-
|
43
|
-
"[#{self.class}] - An error occurred requesting data from the cache. " \
|
44
|
-
"Key: #{key} | Error: #{e.message} | Backtrace: #{e.backtrace}"
|
45
|
-
)
|
40
|
+
handle_error(e, 'requesting data from the cache')
|
46
41
|
nil
|
47
42
|
end
|
48
43
|
|
@@ -60,48 +55,42 @@ class OptionalRedisCacheStore
|
|
60
55
|
def set(key, value, expires_in = 0)
|
61
56
|
redis_store.set(key, value, expires_in)
|
62
57
|
rescue => e
|
63
|
-
|
64
|
-
"[#{self.class}] - An error occurred storing data in the cache. " \
|
65
|
-
"Key: #{key} | Error: #{e.message} | Backtrace: #{e.backtrace}"
|
66
|
-
)
|
58
|
+
handle_error(e, 'storing data in the cache')
|
67
59
|
end
|
68
60
|
|
69
61
|
def remove(key)
|
70
62
|
redis_store.remove(key)
|
71
63
|
rescue => e
|
72
|
-
|
73
|
-
"[#{self.class}] - An error occurred removing data from the cache. " \
|
74
|
-
"Key: #{key} | Error: #{e.message} | Backtrace: #{e.backtrace}"
|
75
|
-
)
|
64
|
+
handle_error(e, 'removing data from the cache')
|
76
65
|
end
|
77
66
|
|
78
67
|
def exist?(key)
|
79
68
|
redis_store.exist?(key)
|
80
69
|
rescue => e
|
81
|
-
|
82
|
-
"[#{self.class}] - An error occurred checking if a key exists in the cache. " \
|
83
|
-
"Key: #{key} | Error: #{e.message} | Backtrace: #{e.backtrace}"
|
84
|
-
)
|
70
|
+
handle_error(e, 'checking if a key exists in the cache')
|
85
71
|
false
|
86
72
|
end
|
87
73
|
|
88
74
|
def ping
|
89
75
|
redis_store.ping
|
90
76
|
rescue => e
|
91
|
-
|
92
|
-
"[#{self.class}] - An error occurred checking pinging the cache. " \
|
93
|
-
"Error: #{e.message} | Backtrace: #{e.backtrace}"
|
94
|
-
)
|
77
|
+
handle_error(e, 'pinging the cache')
|
95
78
|
false
|
96
79
|
end
|
97
80
|
|
98
81
|
def shutdown
|
99
82
|
redis_store.shutdown
|
100
83
|
rescue => e
|
101
|
-
|
102
|
-
"[#{self.class}] - An error occurred checking shutting down the connection pool. " \
|
103
|
-
"Error: #{e.message} | Backtrace: #{e.backtrace}"
|
104
|
-
)
|
84
|
+
handle_error(e, 'shutting down the connection pool')
|
105
85
|
false
|
106
86
|
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def handle_error(ex, msg)
|
91
|
+
@logger.error do
|
92
|
+
"[#{self.class}] - An error occurred #{msg}. " \
|
93
|
+
"Error: #{ex.message} | Backtrace: #{ex.backtrace}"
|
94
|
+
end
|
95
|
+
end
|
107
96
|
end
|
@@ -3,10 +3,6 @@ class RedisCacheStore
|
|
3
3
|
def initialize(namespace = nil, config = nil)
|
4
4
|
@connection_pool = RedisConnectionPool.new(config)
|
5
5
|
|
6
|
-
unless RUBY_PLATFORM == 'java'
|
7
|
-
require 'oj'
|
8
|
-
end
|
9
|
-
|
10
6
|
@namespace = namespace
|
11
7
|
@config = config
|
12
8
|
|
@@ -141,19 +137,11 @@ class RedisCacheStore
|
|
141
137
|
private
|
142
138
|
|
143
139
|
def serialize(object)
|
144
|
-
|
145
|
-
Marshal::dump(object)
|
146
|
-
else
|
147
|
-
Oj.dump(object)
|
148
|
-
end
|
140
|
+
Oj.dump(object)
|
149
141
|
end
|
150
142
|
|
151
143
|
def deserialize(object)
|
152
|
-
|
153
|
-
Marshal::load(object)
|
154
|
-
else
|
155
|
-
Oj.load(object)
|
156
|
-
end
|
144
|
+
Oj.load(object)
|
157
145
|
end
|
158
146
|
|
159
147
|
def build_key(key)
|
data/lib/cache_store_redis.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cache_store_redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vaughanbrittonsage
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,16 +42,44 @@ dependencies:
|
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: timecop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: redis
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,7 +123,7 @@ files:
|
|
95
123
|
- lib/cache_store_redis/redis_connection.rb
|
96
124
|
- lib/cache_store_redis/redis_connection_pool.rb
|
97
125
|
- lib/cache_store_redis/version.rb
|
98
|
-
homepage: https://github.com/
|
126
|
+
homepage: https://github.com/sage/cache_store
|
99
127
|
licenses:
|
100
128
|
- MIT
|
101
129
|
metadata: {}
|
@@ -114,8 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
142
|
- !ruby/object:Gem::Version
|
115
143
|
version: '0'
|
116
144
|
requirements: []
|
117
|
-
|
118
|
-
rubygems_version: 2.5.1
|
145
|
+
rubygems_version: 3.0.2
|
119
146
|
signing_key:
|
120
147
|
specification_version: 4
|
121
148
|
summary: This is the redis cache_store implementation.
|