memcached_store 2.0.2 → 2.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/active_support/cache/memcached_store.rb +35 -23
- data/lib/memcached_store/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b0a184a4116f8347e79e8043dc0dc6cf84348a50b3b25fa446a0bbb7cd30f130
|
4
|
+
data.tar.gz: d4f927b0ba9d5990fae0959045be9e518bcbff598af0eb1eb35b1196a80e4aa5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40bd828913b63212bd06091725700f2b0ea4d4de98c46dbecbcab3d9562c8d1926971b2e87cf0408bb1c5894ae23d1903dcb59181b99a85f1789851e4064fead
|
7
|
+
data.tar.gz: afd215ae18c02bfa2d7aac757d5d991b1164577de5d80af9e677d78c08af605fecb5f9cf0778241949fc1f6e8af197004d1411ce904925df2878355ac070e524
|
@@ -58,6 +58,8 @@ module ActiveSupport
|
|
58
58
|
|
59
59
|
attr_accessor :read_only, :swallow_exceptions
|
60
60
|
|
61
|
+
prepend(Strategy::LocalCache)
|
62
|
+
|
61
63
|
def initialize(*addresses, **options)
|
62
64
|
addresses = addresses.flatten
|
63
65
|
options[:codec] ||= Codec.new
|
@@ -67,17 +69,28 @@ module ActiveSupport
|
|
67
69
|
super(options)
|
68
70
|
|
69
71
|
if addresses.first.is_a?(Memcached)
|
70
|
-
@
|
72
|
+
@connection = addresses.first
|
71
73
|
raise "Memcached::Rails is no longer supported, "\
|
72
|
-
"use a Memcached instance instead" if @
|
74
|
+
"use a Memcached instance instead" if @connection.is_a?(Memcached::Rails)
|
73
75
|
else
|
74
76
|
mem_cache_options = options.dup
|
75
77
|
servers = mem_cache_options.delete(:servers)
|
76
78
|
UNIVERSAL_OPTIONS.each { |name| mem_cache_options.delete(name) }
|
77
|
-
@
|
79
|
+
@connection = Memcached.new([*addresses, *servers], mem_cache_options)
|
78
80
|
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def append(name, value, options = nil)
|
84
|
+
return true if read_only
|
85
|
+
options = merged_options(options)
|
86
|
+
normalized_key = normalize_key(name, options)
|
79
87
|
|
80
|
-
|
88
|
+
handle_exceptions(return_value_on_error: nil, on_miss: false, miss_exceptions: [Memcached::NotStored]) do
|
89
|
+
instrument(:append, name) do
|
90
|
+
@connection.append(normalized_key, value)
|
91
|
+
end
|
92
|
+
true
|
93
|
+
end
|
81
94
|
end
|
82
95
|
|
83
96
|
def write(*)
|
@@ -100,7 +113,7 @@ module ActiveSupport
|
|
100
113
|
|
101
114
|
handle_exceptions(return_value_on_error: {}) do
|
102
115
|
instrument(:read_multi, names, options) do
|
103
|
-
if raw_values = @
|
116
|
+
if raw_values = @connection.get(keys_to_names.keys)
|
104
117
|
raw_values.each do |key, value|
|
105
118
|
entry = deserialize_entry(value)
|
106
119
|
values[keys_to_names[key]] = entry.value unless entry.expired?
|
@@ -117,11 +130,11 @@ module ActiveSupport
|
|
117
130
|
|
118
131
|
handle_exceptions(return_value_on_error: false) do
|
119
132
|
instrument(:cas, name, options) do
|
120
|
-
@
|
133
|
+
@connection.cas(key, expiration(options)) do |raw_value|
|
121
134
|
entry = deserialize_entry(raw_value)
|
122
135
|
value = yield entry.value
|
123
136
|
break true if read_only
|
124
|
-
serialize_entry(Entry.new(value, options), options)
|
137
|
+
serialize_entry(Entry.new(value, **options), options)
|
125
138
|
end
|
126
139
|
end
|
127
140
|
true
|
@@ -136,7 +149,7 @@ module ActiveSupport
|
|
136
149
|
|
137
150
|
handle_exceptions(return_value_on_error: false) do
|
138
151
|
instrument(:cas_multi, names, options) do
|
139
|
-
@
|
152
|
+
@connection.cas(keys_to_names.keys, expiration(options)) do |raw_values|
|
140
153
|
values = {}
|
141
154
|
|
142
155
|
raw_values.each do |key, raw_value|
|
@@ -149,7 +162,7 @@ module ActiveSupport
|
|
149
162
|
break true if read_only
|
150
163
|
|
151
164
|
serialized_values = values.map do |name, value|
|
152
|
-
[normalize_key(name, options), serialize_entry(Entry.new(value, options), options)]
|
165
|
+
[normalize_key(name, options), serialize_entry(Entry.new(value, **options), options)]
|
153
166
|
end
|
154
167
|
|
155
168
|
Hash[serialized_values]
|
@@ -163,7 +176,7 @@ module ActiveSupport
|
|
163
176
|
options = merged_options(options)
|
164
177
|
handle_exceptions(return_value_on_error: nil) do
|
165
178
|
instrument(:increment, name, amount: amount) do
|
166
|
-
@
|
179
|
+
@connection.incr(normalize_key(name, options), amount)
|
167
180
|
end
|
168
181
|
end
|
169
182
|
end
|
@@ -172,20 +185,20 @@ module ActiveSupport
|
|
172
185
|
options = merged_options(options)
|
173
186
|
handle_exceptions(return_value_on_error: nil) do
|
174
187
|
instrument(:decrement, name, amount: amount) do
|
175
|
-
@
|
188
|
+
@connection.decr(normalize_key(name, options), amount)
|
176
189
|
end
|
177
190
|
end
|
178
191
|
end
|
179
192
|
|
180
193
|
def clear(options = nil)
|
181
194
|
ActiveSupport::Notifications.instrument("cache_clear.active_support", options || {}) do
|
182
|
-
@
|
195
|
+
@connection.flush
|
183
196
|
end
|
184
197
|
end
|
185
198
|
|
186
199
|
def stats
|
187
200
|
ActiveSupport::Notifications.instrument("cache_stats.active_support") do
|
188
|
-
@
|
201
|
+
@connection.stats
|
189
202
|
end
|
190
203
|
end
|
191
204
|
|
@@ -195,7 +208,7 @@ module ActiveSupport
|
|
195
208
|
|
196
209
|
def reset #:nodoc:
|
197
210
|
handle_exceptions(return_value_on_error: false) do
|
198
|
-
@
|
211
|
+
@connection.reset
|
199
212
|
end
|
200
213
|
end
|
201
214
|
|
@@ -203,7 +216,7 @@ module ActiveSupport
|
|
203
216
|
|
204
217
|
def read_entry(key, _options) # :nodoc:
|
205
218
|
handle_exceptions(return_value_on_error: nil) do
|
206
|
-
deserialize_entry(@
|
219
|
+
deserialize_entry(@connection.get(escape_key(key)))
|
207
220
|
end
|
208
221
|
end
|
209
222
|
|
@@ -213,7 +226,7 @@ module ActiveSupport
|
|
213
226
|
expires_in = expiration(options)
|
214
227
|
value = serialize_entry(entry, options)
|
215
228
|
handle_exceptions(return_value_on_error: false) do
|
216
|
-
@
|
229
|
+
@connection.send(method, escape_key(key), value, expires_in)
|
217
230
|
true
|
218
231
|
end
|
219
232
|
end
|
@@ -221,7 +234,7 @@ module ActiveSupport
|
|
221
234
|
def delete_entry(key, _options) # :nodoc:
|
222
235
|
return true if read_only
|
223
236
|
handle_exceptions(return_value_on_error: false, on_miss: true) do
|
224
|
-
@
|
237
|
+
@connection.delete(escape_key(key))
|
225
238
|
true
|
226
239
|
end
|
227
240
|
end
|
@@ -257,7 +270,7 @@ module ActiveSupport
|
|
257
270
|
|
258
271
|
def deserialize_entry(value)
|
259
272
|
if value
|
260
|
-
value.is_a?(Entry) ? value : Entry.new(value,
|
273
|
+
value.is_a?(Entry) ? value : Entry.new(value, compress: false)
|
261
274
|
end
|
262
275
|
end
|
263
276
|
|
@@ -271,16 +284,15 @@ module ActiveSupport
|
|
271
284
|
|
272
285
|
def expiration(options)
|
273
286
|
expires_in = options[:expires_in].to_i
|
274
|
-
if expires_in > 0 && !options[:raw]
|
275
|
-
|
276
|
-
expires_in += 5.minutes.to_i
|
287
|
+
if expires_in > 0 && options[:race_condition_ttl] && !options[:raw]
|
288
|
+
expires_in += options[:race_condition_ttl].to_i
|
277
289
|
end
|
278
290
|
expires_in
|
279
291
|
end
|
280
292
|
|
281
|
-
def handle_exceptions(return_value_on_error:, on_miss: return_value_on_error)
|
293
|
+
def handle_exceptions(return_value_on_error:, on_miss: return_value_on_error, miss_exceptions: [])
|
282
294
|
yield
|
283
|
-
rescue Memcached::NotFound, Memcached::ConnectionDataExists
|
295
|
+
rescue Memcached::NotFound, Memcached::ConnectionDataExists, *miss_exceptions
|
284
296
|
on_miss
|
285
297
|
rescue Memcached::Error => e
|
286
298
|
log_warning(e)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memcached_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Camilo Lopez
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2020-10-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
@@ -75,7 +75,8 @@ files:
|
|
75
75
|
homepage: https://github.com/Shopify/memcached_store/
|
76
76
|
licenses:
|
77
77
|
- MIT
|
78
|
-
metadata:
|
78
|
+
metadata:
|
79
|
+
allowed_push_host: https://rubygems.org
|
79
80
|
post_install_message:
|
80
81
|
rdoc_options: []
|
81
82
|
require_paths:
|
@@ -91,8 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
92
|
- !ruby/object:Gem::Version
|
92
93
|
version: '0'
|
93
94
|
requirements: []
|
94
|
-
|
95
|
-
rubygems_version: 2.6.14
|
95
|
+
rubygems_version: 3.0.3
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: Plugin-able Memcached adapters to add features (compression, safety)
|