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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 604df981c587ff19ef1bd833c79f95d0716051bd
4
- data.tar.gz: cd75d95d121d1969b8ffe73d858b9699a51a3000
2
+ SHA256:
3
+ metadata.gz: b0a184a4116f8347e79e8043dc0dc6cf84348a50b3b25fa446a0bbb7cd30f130
4
+ data.tar.gz: d4f927b0ba9d5990fae0959045be9e518bcbff598af0eb1eb35b1196a80e4aa5
5
5
  SHA512:
6
- metadata.gz: 82bec692dca6c4e55e809ab7a413681e8d3737cc3a59a9cd20c8b505a1506eb6f7a1e3d0e6bb0c91a6da5b0e1c3e9f330692f04e729a6213fcec9a5375ff8adf
7
- data.tar.gz: ba4c196fb7bbdc0cbae3e03568ef0d2dfea8577a5f66a7ecaa1c4afc52116f4f63ef3d0d2bc848e7bffd1eb735ad031ca00cbf504d94dc3d232caa669f632c37
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
- @data = addresses.first
72
+ @connection = addresses.first
71
73
  raise "Memcached::Rails is no longer supported, "\
72
- "use a Memcached instance instead" if @data.is_a?(Memcached::Rails)
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
- @data = Memcached.new([*addresses, *servers], mem_cache_options)
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
- extend Strategy::LocalCache
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 = @data.get(keys_to_names.keys)
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
- @data.cas(key, expiration(options)) do |raw_value|
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
- @data.cas(keys_to_names.keys, expiration(options)) do |raw_values|
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
- @data.incr(normalize_key(name, options), amount)
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
- @data.decr(normalize_key(name, options), amount)
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
- @data.flush
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
- @data.stats
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
- @data.reset
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(@data.get(escape_key(key)))
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
- @data.send(method, escape_key(key), value, expires_in)
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
- @data.delete(escape_key(key))
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, compresss: false)
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
- # Set the memcache expire a few minutes in the future to support race condition ttls on read
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)
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module MemcachedStore
3
- VERSION = "2.0.2"
3
+ VERSION = "2.1.6"
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.0.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: 2018-09-25 00:00:00.000000000 Z
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
- rubyforge_project:
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)