memcached_store 2.2.1 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_support/cache/memcached_store.rb +81 -39
- data/lib/memcached_store/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdd4f8408b915953e5dac445736ee15ddb7db1208acf365fdecb5a03b389a8e8
|
4
|
+
data.tar.gz: 218294aa36469941f5ef0a6609d31687ead001e25c42dc1cf8b565b5e36e395c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 774a57bfa30dd07824d9a8b4bcb394de38fea2e59a2cae280bc583dcd92d3ece84241c5bffc54162d903f0f594e7fbb50b7f54c19f56fe74744c8089af60c93d
|
7
|
+
data.tar.gz: b0b35daa5e372df41f17d51c41df7daa393c441447342800e213e1333bdec1b574ed0cd3f72e2523105f56fcce73b34cf65ecceb68f30ca26d2058413b611484
|
@@ -212,62 +212,104 @@ module ActiveSupport
|
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
215
|
-
|
215
|
+
private
|
216
216
|
|
217
|
-
|
218
|
-
|
219
|
-
|
217
|
+
if private_method_defined?(:read_serialized_entry)
|
218
|
+
class LocalStore < Strategy::LocalCache::LocalStore
|
219
|
+
def write_entry(_key, entry)
|
220
|
+
if entry.is_a?(Entry)
|
221
|
+
entry.dup_value!
|
222
|
+
end
|
223
|
+
super
|
224
|
+
end
|
225
|
+
|
226
|
+
def fetch_entry(key)
|
227
|
+
entry = @data.fetch(key) do
|
228
|
+
new_entry = yield
|
229
|
+
if entry.is_a?(Entry)
|
230
|
+
new_entry.dup_value!
|
231
|
+
end
|
232
|
+
@data[key] = new_entry
|
233
|
+
end
|
234
|
+
entry = entry.dup
|
235
|
+
|
236
|
+
if entry.is_a?(Entry)
|
237
|
+
entry.dup_value!
|
238
|
+
end
|
239
|
+
|
240
|
+
entry
|
241
|
+
end
|
220
242
|
end
|
221
|
-
end
|
222
243
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
value = serialize_entry(entry, options)
|
228
|
-
handle_exceptions(return_value_on_error: false) do
|
229
|
-
@connection.send(method, escape_key(key), value, expires_in)
|
230
|
-
true
|
244
|
+
module LocalCacheDup
|
245
|
+
def with_local_cache
|
246
|
+
use_temporary_local_cache(LocalStore.new) { yield }
|
247
|
+
end
|
231
248
|
end
|
232
|
-
|
249
|
+
prepend LocalCacheDup
|
233
250
|
|
234
|
-
|
235
|
-
|
236
|
-
handle_exceptions(return_value_on_error: false, on_miss: true) do
|
237
|
-
@connection.delete(escape_key(key))
|
238
|
-
true
|
251
|
+
def read_entry(key, **options) # :nodoc:
|
252
|
+
deserialize_entry(read_serialized_entry(key, **options))
|
239
253
|
end
|
240
|
-
end
|
241
254
|
|
242
|
-
|
255
|
+
def read_serialized_entry(key, **)
|
256
|
+
handle_exceptions(return_value_on_error: nil) do
|
257
|
+
@connection.get(key)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
def write_entry(key, entry, **options) # :nodoc:
|
262
|
+
return true if read_only
|
243
263
|
|
244
|
-
|
245
|
-
def normalize_key(key, options)
|
246
|
-
escape_key(namespaced_key(key, options))
|
264
|
+
write_serialized_entry(key, serialize_entry(entry, **options), **options)
|
247
265
|
end
|
248
266
|
|
249
|
-
def
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
267
|
+
def write_serialized_entry(key, value, **options)
|
268
|
+
method = options && options[:unless_exist] ? :add : :set
|
269
|
+
expires_in = expiration(options)
|
270
|
+
handle_exceptions(return_value_on_error: false) do
|
271
|
+
@connection.send(method, key, value, expires_in)
|
272
|
+
true
|
273
|
+
end
|
255
274
|
end
|
256
275
|
else
|
257
|
-
def
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
# When we remove support to Rails 5.1 we can change the code to use ActiveSupport::Digest
|
262
|
-
key = "#{key[0, 213]}:md5:#{::Digest::MD5.hexdigest(key)}" if key.size > 250
|
263
|
-
key
|
276
|
+
def read_entry(key, _options) # :nodoc:
|
277
|
+
handle_exceptions(return_value_on_error: nil) do
|
278
|
+
deserialize_entry(@connection.get(key))
|
279
|
+
end
|
264
280
|
end
|
265
281
|
|
266
|
-
def
|
267
|
-
|
282
|
+
def write_entry(key, entry, options) # :nodoc:
|
283
|
+
return true if read_only
|
284
|
+
method = options && options[:unless_exist] ? :add : :set
|
285
|
+
expires_in = expiration(options)
|
286
|
+
value = serialize_entry(entry, options)
|
287
|
+
handle_exceptions(return_value_on_error: false) do
|
288
|
+
@connection.send(method, key, value, expires_in)
|
289
|
+
true
|
290
|
+
end
|
268
291
|
end
|
269
292
|
end
|
270
293
|
|
294
|
+
def delete_entry(key, _options) # :nodoc:
|
295
|
+
return true if read_only
|
296
|
+
handle_exceptions(return_value_on_error: false, on_miss: true) do
|
297
|
+
@connection.delete(key)
|
298
|
+
true
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
private
|
303
|
+
|
304
|
+
def normalize_key(key, options)
|
305
|
+
key = super.dup
|
306
|
+
key = key.force_encoding(Encoding::ASCII_8BIT)
|
307
|
+
key = key.gsub(ESCAPE_KEY_CHARS) { |match| "%#{match.getbyte(0).to_s(16).upcase}" }
|
308
|
+
# When we remove support to Rails 5.1 we can change the code to use ActiveSupport::Digest
|
309
|
+
key = "#{key[0, 213]}:md5:#{::Digest::MD5.hexdigest(key)}" if key.size > 250
|
310
|
+
key
|
311
|
+
end
|
312
|
+
|
271
313
|
def deserialize_entry(value)
|
272
314
|
unless value.nil?
|
273
315
|
value.is_a?(Entry) ? value : Entry.new(value, compress: false)
|
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.3.0
|
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: 2021-
|
14
|
+
date: 2021-07-26 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
@@ -19,14 +19,14 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '6'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '6'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: memcached
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,14 +113,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
113
|
requirements:
|
114
114
|
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: 2.
|
116
|
+
version: 2.6.0
|
117
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
118
|
requirements:
|
119
119
|
- - ">="
|
120
120
|
- !ruby/object:Gem::Version
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
|
-
rubygems_version: 3.2.
|
123
|
+
rubygems_version: 3.2.20
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Plugin-able Memcached adapters to add features (compression, safety)
|