memcached_store 2.3.0 → 2.3.2
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 +4 -4
- data/lib/active_support/cache/memcached_store.rb +47 -13
- data/lib/memcached_store/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51f58b245ce09f4f36a9f095684357fecc3e6ec3a7dfcfe5d37c532c94f3476a
|
4
|
+
data.tar.gz: b5062194ad1fc584c122bfedfc2e9b11f04e05080c702753623b1dc599042885
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a0023120d7e6107600871075ece41c802d076fa670ba2ad588bd0a15017544499c88a281f8ab0f6ce067f6179728af0a991013fb7ed0851305776b2cf11b853
|
7
|
+
data.tar.gz: 8aac93c1733e645bbc683eb3d8e6e2099ef553866f0fc9a7278bb4e008190e09df783963bca99c72d00152ecf0bf94eee29582146f5e2c411d587697a5062158
|
@@ -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
|
@@ -66,7 +67,13 @@ module ActiveSupport
|
|
66
67
|
@swallow_exceptions = true
|
67
68
|
@swallow_exceptions = options.delete(:swallow_exceptions) if options.key?(:swallow_exceptions)
|
68
69
|
|
69
|
-
|
70
|
+
if options.key?(:coder)
|
71
|
+
raise ArgumentError, "ActiveSupport::Cache::MemcachedStore doesn't support custom coders"
|
72
|
+
end
|
73
|
+
|
74
|
+
# We don't use a coder, so we set it to nil so Active Support don't think we're using
|
75
|
+
# a deprecated one.
|
76
|
+
super(options.merge(coder: nil))
|
70
77
|
|
71
78
|
if addresses.first.is_a?(Memcached)
|
72
79
|
@connection = addresses.first
|
@@ -127,18 +134,27 @@ module ActiveSupport
|
|
127
134
|
def cas(name, options = nil)
|
128
135
|
options = merged_options(options)
|
129
136
|
key = normalize_key(name, options)
|
137
|
+
payload = nil
|
130
138
|
|
131
|
-
handle_exceptions(return_value_on_error: false) do
|
139
|
+
success = handle_exceptions(return_value_on_error: false) do
|
132
140
|
instrument(:cas, name, options) do
|
133
141
|
@connection.cas(key, expiration(options)) do |raw_value|
|
134
142
|
entry = deserialize_entry(raw_value)
|
135
143
|
value = yield entry.value
|
136
144
|
break true if read_only
|
137
|
-
serialize_entry(Entry.new(value, **options), options)
|
145
|
+
payload = serialize_entry(Entry.new(value, **options), options)
|
138
146
|
end
|
139
147
|
end
|
140
148
|
true
|
141
149
|
end
|
150
|
+
|
151
|
+
if success
|
152
|
+
local_cache.write_entry(key, payload) if local_cache
|
153
|
+
else
|
154
|
+
local_cache.delete_entry(key) if local_cache
|
155
|
+
end
|
156
|
+
|
157
|
+
success
|
142
158
|
end
|
143
159
|
|
144
160
|
def cas_multi(*names, **options)
|
@@ -147,9 +163,11 @@ module ActiveSupport
|
|
147
163
|
options = merged_options(options)
|
148
164
|
keys_to_names = Hash[names.map { |name| [normalize_key(name, options), name] }]
|
149
165
|
|
166
|
+
sent_payloads = nil
|
167
|
+
|
150
168
|
handle_exceptions(return_value_on_error: false) do
|
151
169
|
instrument(:cas_multi, names, options) do
|
152
|
-
@connection.cas(keys_to_names.keys, expiration(options)) do |raw_values|
|
170
|
+
written_payloads = @connection.cas(keys_to_names.keys, expiration(options)) do |raw_values|
|
153
171
|
values = {}
|
154
172
|
|
155
173
|
raw_values.each do |key, raw_value|
|
@@ -165,8 +183,19 @@ module ActiveSupport
|
|
165
183
|
[normalize_key(name, options), serialize_entry(Entry.new(value, **options), options)]
|
166
184
|
end
|
167
185
|
|
168
|
-
Hash[serialized_values]
|
186
|
+
sent_payloads = Hash[serialized_values]
|
169
187
|
end
|
188
|
+
|
189
|
+
if local_cache && sent_payloads
|
190
|
+
sent_payloads.each_key do |key|
|
191
|
+
if written_payloads.key?(key)
|
192
|
+
local_cache.write_entry(key, written_payloads[key])
|
193
|
+
else
|
194
|
+
local_cache.delete_entry(key)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
170
199
|
true
|
171
200
|
end
|
172
201
|
end
|
@@ -215,21 +244,21 @@ module ActiveSupport
|
|
215
244
|
private
|
216
245
|
|
217
246
|
if private_method_defined?(:read_serialized_entry)
|
218
|
-
class
|
247
|
+
class DupLocalStore < DelegateClass(Strategy::LocalCache::LocalStore)
|
219
248
|
def write_entry(_key, entry)
|
220
249
|
if entry.is_a?(Entry)
|
221
|
-
entry.dup_value!
|
250
|
+
entry.dup_value!
|
222
251
|
end
|
223
252
|
super
|
224
253
|
end
|
225
254
|
|
226
255
|
def fetch_entry(key)
|
227
|
-
entry =
|
256
|
+
entry = super do
|
228
257
|
new_entry = yield
|
229
258
|
if entry.is_a?(Entry)
|
230
259
|
new_entry.dup_value!
|
231
260
|
end
|
232
|
-
|
261
|
+
new_entry
|
233
262
|
end
|
234
263
|
entry = entry.dup
|
235
264
|
|
@@ -241,12 +270,17 @@ module ActiveSupport
|
|
241
270
|
end
|
242
271
|
end
|
243
272
|
|
244
|
-
module
|
245
|
-
|
246
|
-
|
273
|
+
module DupLocalCache
|
274
|
+
private
|
275
|
+
|
276
|
+
def local_cache
|
277
|
+
if local_cache = super
|
278
|
+
DupLocalStore.new(local_cache)
|
279
|
+
end
|
247
280
|
end
|
248
281
|
end
|
249
|
-
|
282
|
+
|
283
|
+
prepend DupLocalCache
|
250
284
|
|
251
285
|
def read_entry(key, **options) # :nodoc:
|
252
286
|
deserialize_entry(read_serialized_entry(key, **options))
|
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.3.
|
4
|
+
version: 2.3.2
|
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: 2023-07-26 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
- !ruby/object:Gem::Version
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
|
-
rubygems_version: 3.
|
123
|
+
rubygems_version: 3.4.16
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Plugin-able Memcached adapters to add features (compression, safety)
|