memcached_store 2.0.3 → 2.2.0
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 +5 -5
- data/lib/active_support/cache/memcached_store.rb +34 -22
- data/lib/memcached_store/version.rb +1 -1
- metadata +35 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9e7243c82d777973585ebe50de354665846e66aed6e03e3464bc076037b291e0
|
4
|
+
data.tar.gz: fd1698923aa5ace4e2ec6ecfbcfc02d04111bd92ba06c3ee85c961440a2d535a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bf90bd2fb5cc5a339dfe0d25c36a35494141ed091759015bfaac4fa913333dc5979220e0f44cb654d974e86aed295287d19e78824c42340af5a0b71b5aa00f2
|
7
|
+
data.tar.gz: d004c8b93109d62d7faec3484c5227d2819b5beaffb67d695f680beb2a7e458484d34f1efef4f2730a442ad1bdfa0eff261b363d65954dee35e2f8da096e2b29
|
@@ -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
|
@@ -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.0
|
4
|
+
version: 2.2.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:
|
14
|
+
date: 2021-05-26 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
@@ -33,14 +33,14 @@ dependencies:
|
|
33
33
|
requirements:
|
34
34
|
- - "~>"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 1.8
|
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
|
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
|
@@ -75,7 +103,8 @@ files:
|
|
75
103
|
homepage: https://github.com/Shopify/memcached_store/
|
76
104
|
licenses:
|
77
105
|
- MIT
|
78
|
-
metadata:
|
106
|
+
metadata:
|
107
|
+
allowed_push_host: https://rubygems.org
|
79
108
|
post_install_message:
|
80
109
|
rdoc_options: []
|
81
110
|
require_paths:
|
@@ -91,8 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
120
|
- !ruby/object:Gem::Version
|
92
121
|
version: '0'
|
93
122
|
requirements: []
|
94
|
-
|
95
|
-
rubygems_version: 2.6.14
|
123
|
+
rubygems_version: 3.2.17
|
96
124
|
signing_key:
|
97
125
|
specification_version: 4
|
98
126
|
summary: Plugin-able Memcached adapters to add features (compression, safety)
|