memcached_store 2.1.6 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0a184a4116f8347e79e8043dc0dc6cf84348a50b3b25fa446a0bbb7cd30f130
4
- data.tar.gz: d4f927b0ba9d5990fae0959045be9e518bcbff598af0eb1eb35b1196a80e4aa5
3
+ metadata.gz: cff56eb9da5ff4283dbdb070dbcccb23fcb59c834a3a4d66e158720b0a594fe6
4
+ data.tar.gz: 306470c390a690087d0bee0628b8f35300fe8330a818d51ec391ba522f3f6441
5
5
  SHA512:
6
- metadata.gz: 40bd828913b63212bd06091725700f2b0ea4d4de98c46dbecbcab3d9562c8d1926971b2e87cf0408bb1c5894ae23d1903dcb59181b99a85f1789851e4064fead
7
- data.tar.gz: afd215ae18c02bfa2d7aac757d5d991b1164577de5d80af9e677d78c08af605fecb5f9cf0778241949fc1f6e8af197004d1411ce904925df2878355ac070e524
6
+ metadata.gz: 4c97659aad0e6f75d89005a2b69306ca3387395b1924f92563c195c97cc812fb82187908c11c557346ec9c1e705c5140f367a0e49b2919ed43487dd4e42dc508
7
+ data.tar.gz: 7c9b0891c23dddfe4f01aba246dd187393207d4a8962f491b358f32d8e0ee83b532eca81f64e670e609d1dfffa294d9a3f22a68bced26291aaff4cbea07f8e01
@@ -1,5 +1,6 @@
1
1
  # file havily based out off https://github.com/rails/rails/blob/3-2-stable/activesupport/lib/active_support/cache/mem_cache_store.rb
2
2
  require 'digest/md5'
3
+ require 'delegate'
3
4
 
4
5
  module ActiveSupport
5
6
  module Cache
@@ -212,64 +213,111 @@ module ActiveSupport
212
213
  end
213
214
  end
214
215
 
215
- protected
216
+ private
216
217
 
217
- def read_entry(key, _options) # :nodoc:
218
- handle_exceptions(return_value_on_error: nil) do
219
- deserialize_entry(@connection.get(escape_key(key)))
218
+ if private_method_defined?(:read_serialized_entry)
219
+ class DupLocalStore < DelegateClass(Strategy::LocalCache::LocalStore)
220
+ def write_entry(_key, entry)
221
+ if entry.is_a?(Entry)
222
+ entry.dup_value!
223
+ end
224
+ super
225
+ end
226
+
227
+ def fetch_entry(key)
228
+ entry = super do
229
+ new_entry = yield
230
+ if entry.is_a?(Entry)
231
+ new_entry.dup_value!
232
+ end
233
+ new_entry
234
+ end
235
+ entry = entry.dup
236
+
237
+ if entry.is_a?(Entry)
238
+ entry.dup_value!
239
+ end
240
+
241
+ entry
242
+ end
220
243
  end
221
- end
222
244
 
223
- def write_entry(key, entry, options) # :nodoc:
224
- return true if read_only
225
- method = options && options[:unless_exist] ? :add : :set
226
- expires_in = expiration(options)
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
245
+ module DupLocalCache
246
+ private
247
+
248
+ def local_cache
249
+ if local_cache = super
250
+ DupLocalStore.new(local_cache)
251
+ end
252
+ end
231
253
  end
232
- end
233
254
 
234
- def delete_entry(key, _options) # :nodoc:
235
- return true if read_only
236
- handle_exceptions(return_value_on_error: false, on_miss: true) do
237
- @connection.delete(escape_key(key))
238
- true
255
+ prepend DupLocalCache
256
+
257
+ def read_entry(key, **options) # :nodoc:
258
+ deserialize_entry(read_serialized_entry(key, **options))
239
259
  end
240
- end
241
260
 
242
- private
261
+ def read_serialized_entry(key, **)
262
+ handle_exceptions(return_value_on_error: nil) do
263
+ @connection.get(key)
264
+ end
265
+ end
266
+
267
+ def write_entry(key, entry, **options) # :nodoc:
268
+ return true if read_only
243
269
 
244
- if ActiveSupport::VERSION::MAJOR < 5
245
- def normalize_key(key, options)
246
- escape_key(namespaced_key(key, options))
270
+ write_serialized_entry(key, serialize_entry(entry, **options), **options)
247
271
  end
248
272
 
249
- def escape_key(key)
250
- key = key.to_s.dup
251
- key = key.force_encoding(Encoding::ASCII_8BIT)
252
- key = key.gsub(ESCAPE_KEY_CHARS) { |match| "%#{match.getbyte(0).to_s(16).upcase}" }
253
- key = "#{key[0, 213]}:md5:#{Digest::MD5.hexdigest(key)}" if key.size > 250
254
- key
273
+ def write_serialized_entry(key, value, **options)
274
+ method = options && options[:unless_exist] ? :add : :set
275
+ expires_in = expiration(options)
276
+ handle_exceptions(return_value_on_error: false) do
277
+ @connection.send(method, key, value, expires_in)
278
+ true
279
+ end
255
280
  end
256
281
  else
257
- def normalize_key(key, options)
258
- key = super.dup
259
- key = key.force_encoding(Encoding::ASCII_8BIT)
260
- key = key.gsub(ESCAPE_KEY_CHARS) { |match| "%#{match.getbyte(0).to_s(16).upcase}" }
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
282
+ def read_entry(key, _options) # :nodoc:
283
+ handle_exceptions(return_value_on_error: nil) do
284
+ deserialize_entry(@connection.get(key))
285
+ end
286
+ end
287
+
288
+ def write_entry(key, entry, options) # :nodoc:
289
+ return true if read_only
290
+ method = options && options[:unless_exist] ? :add : :set
291
+ expires_in = expiration(options)
292
+ value = serialize_entry(entry, options)
293
+ handle_exceptions(return_value_on_error: false) do
294
+ @connection.send(method, key, value, expires_in)
295
+ true
296
+ end
264
297
  end
298
+ end
265
299
 
266
- def escape_key(key)
267
- key
300
+ def delete_entry(key, _options) # :nodoc:
301
+ return true if read_only
302
+ handle_exceptions(return_value_on_error: false, on_miss: true) do
303
+ @connection.delete(key)
304
+ true
268
305
  end
269
306
  end
270
307
 
308
+ private
309
+
310
+ def normalize_key(key, options)
311
+ key = super.dup
312
+ key = key.force_encoding(Encoding::ASCII_8BIT)
313
+ key = key.gsub(ESCAPE_KEY_CHARS) { |match| "%#{match.getbyte(0).to_s(16).upcase}" }
314
+ # When we remove support to Rails 5.1 we can change the code to use ActiveSupport::Digest
315
+ key = "#{key[0, 213]}:md5:#{::Digest::MD5.hexdigest(key)}" if key.size > 250
316
+ key
317
+ end
318
+
271
319
  def deserialize_entry(value)
272
- if value
320
+ unless value.nil?
273
321
  value.is_a?(Entry) ? value : Entry.new(value, compress: false)
274
322
  end
275
323
  end
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module MemcachedStore
3
- VERSION = "2.1.6"
3
+ VERSION = "2.3.1"
4
4
  end
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.1.6
4
+ version: 2.3.1
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: 2020-10-27 00:00:00.000000000 Z
14
+ date: 2021-08-02 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
@@ -19,28 +19,28 @@ dependencies:
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: '4'
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: '4'
29
+ version: '6'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: memcached
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
34
  - - "~>"
35
35
  - !ruby/object:Gem::Version
36
- version: 1.8.0
36
+ version: '1.8'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - "~>"
42
42
  - !ruby/object:Gem::Version
43
- version: 1.8.0
43
+ version: '1.8'
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: rake
46
46
  requirement: !ruby/object:Gem::Requirement
@@ -55,6 +55,34 @@ dependencies:
55
55
  - - ">="
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
+ - !ruby/object:Gem::Dependency
59
+ name: mocha
60
+ requirement: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ - !ruby/object:Gem::Dependency
73
+ name: timecop
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
58
86
  description: Plugin-able Memcached adapters to add features (compression, safety)
59
87
  email:
60
88
  - camilo@camilolopez.com
@@ -85,14 +113,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
85
113
  requirements:
86
114
  - - ">="
87
115
  - !ruby/object:Gem::Version
88
- version: 2.2.0
116
+ version: 2.6.0
89
117
  required_rubygems_version: !ruby/object:Gem::Requirement
90
118
  requirements:
91
119
  - - ">="
92
120
  - !ruby/object:Gem::Version
93
121
  version: '0'
94
122
  requirements: []
95
- rubygems_version: 3.0.3
123
+ rubygems_version: 3.2.20
96
124
  signing_key:
97
125
  specification_version: 4
98
126
  summary: Plugin-able Memcached adapters to add features (compression, safety)