libmemcached_store 0.8.0 → 0.8.1
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
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bdacb0e84cc9933294795e0457a53a8057112d9
|
4
|
+
data.tar.gz: a6f3781d7d091169119a24a399af676cf9196c04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07c4437327c1b4faf968a0e63f107c689a35e2a33731de239bd234e75a9628b10ec28544e45626ef28ad5adf14b27fe6749313f63f89c90f4b2e0926bd285581
|
7
|
+
data.tar.gz: 1a1b3dd17f528032b63f8e6afb8a5f58884dd49a60531d990d7fc25d7a345ab5a38090d17f7cbc85aa0b8b5ffa121f7e28f5f6a4f9bf35de3df1b09c7c943701
|
@@ -62,7 +62,7 @@ module ActiveSupport
|
|
62
62
|
end
|
63
63
|
|
64
64
|
# memcached returns a fixnum on increment, but the value that is stored is raw / a string
|
65
|
-
def increment(key, amount, options={})
|
65
|
+
def increment(key, amount = 1, options={})
|
66
66
|
result = super
|
67
67
|
if result && (cache = local_cache)
|
68
68
|
cache.write(key, result.to_s)
|
@@ -71,7 +71,7 @@ module ActiveSupport
|
|
71
71
|
end
|
72
72
|
|
73
73
|
# memcached returns a fixnum on decrement, but the value that is stored is raw / a string
|
74
|
-
def decrement(key, amount, options={})
|
74
|
+
def decrement(key, amount = 1, options={})
|
75
75
|
result = super
|
76
76
|
if result && (cache = local_cache)
|
77
77
|
cache.write(key, result.to_s)
|
@@ -91,7 +91,7 @@ module ActiveSupport
|
|
91
91
|
if options && options[:race_condition_ttl] && options[:expires_in]
|
92
92
|
fetch_with_race_condition_ttl(key, options, &block)
|
93
93
|
else
|
94
|
-
key =
|
94
|
+
key = normalize_key(key)
|
95
95
|
unless options && options[:force]
|
96
96
|
entry = instrument(:read, key, options) do |payload|
|
97
97
|
read_entry(key, options).tap do |result|
|
@@ -120,7 +120,7 @@ module ActiveSupport
|
|
120
120
|
end
|
121
121
|
|
122
122
|
def read(key, options = nil)
|
123
|
-
key =
|
123
|
+
key = normalize_key(key)
|
124
124
|
instrument(:read, key, options) do |payload|
|
125
125
|
entry = read_entry(key, options)
|
126
126
|
payload[:hit] = !!entry if payload
|
@@ -129,24 +129,24 @@ module ActiveSupport
|
|
129
129
|
end
|
130
130
|
|
131
131
|
def write(key, value, options = nil)
|
132
|
-
key =
|
132
|
+
key = normalize_key(key)
|
133
133
|
instrument(:write, key, options) do |payload|
|
134
134
|
write_entry(key, value, options)
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
138
|
def delete(key, options = nil)
|
139
|
-
key =
|
139
|
+
key = normalize_key(key)
|
140
140
|
instrument(:delete, key) do |payload|
|
141
141
|
delete_entry(key, options)
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
145
|
def exist?(key, options = nil)
|
146
|
-
key =
|
146
|
+
key = normalize_key(key)
|
147
147
|
instrument(:exist?, key) do |payload|
|
148
148
|
if @cache.respond_to?(:exist)
|
149
|
-
@cache.exist(
|
149
|
+
@cache.exist(key)
|
150
150
|
true
|
151
151
|
else
|
152
152
|
read_entry(key, options) != nil
|
@@ -157,9 +157,9 @@ module ActiveSupport
|
|
157
157
|
end
|
158
158
|
|
159
159
|
def increment(key, amount = 1, options = nil)
|
160
|
-
key =
|
160
|
+
key = normalize_key(key)
|
161
161
|
instrument(:increment, key, amount: amount) do
|
162
|
-
@cache.incr(
|
162
|
+
@cache.incr(key, amount)
|
163
163
|
end
|
164
164
|
rescue Memcached::NotFound
|
165
165
|
nil
|
@@ -169,9 +169,9 @@ module ActiveSupport
|
|
169
169
|
end
|
170
170
|
|
171
171
|
def decrement(key, amount = 1, options = nil)
|
172
|
-
key =
|
172
|
+
key = normalize_key(key)
|
173
173
|
instrument(:decrement, key, amount: amount) do
|
174
|
-
@cache.decr(
|
174
|
+
@cache.decr(key, amount)
|
175
175
|
end
|
176
176
|
rescue Memcached::NotFound
|
177
177
|
nil
|
@@ -186,7 +186,7 @@ module ActiveSupport
|
|
186
186
|
|
187
187
|
return {} if names.empty?
|
188
188
|
|
189
|
-
mapping = Hash[names.map {|name| [
|
189
|
+
mapping = Hash[names.map {|name| [normalize_key(name), name] }]
|
190
190
|
keys = mapping.keys
|
191
191
|
raw_values, flags = instrument(:read_multi, keys, options) do
|
192
192
|
@cache.get(keys, false, true)
|
@@ -216,7 +216,7 @@ module ActiveSupport
|
|
216
216
|
|
217
217
|
def read_entry(key, options = nil)
|
218
218
|
options ||= {}
|
219
|
-
raw_value, flags = @cache.get(
|
219
|
+
raw_value, flags = @cache.get(key, false, true)
|
220
220
|
value = deserialize(raw_value, options[:raw], flags)
|
221
221
|
convert_race_condition_entry(value, options)
|
222
222
|
rescue Memcached::NotFound
|
@@ -237,7 +237,7 @@ module ActiveSupport
|
|
237
237
|
flags |= FLAG_COMPRESSED
|
238
238
|
end
|
239
239
|
|
240
|
-
@cache.send(method,
|
240
|
+
@cache.send(method, key, entry, options[:expires_in].to_i, false, flags)
|
241
241
|
true
|
242
242
|
rescue Memcached::Error => e
|
243
243
|
log_error(e)
|
@@ -245,7 +245,7 @@ module ActiveSupport
|
|
245
245
|
end
|
246
246
|
|
247
247
|
def delete_entry(key, options = nil)
|
248
|
-
@cache.delete(
|
248
|
+
@cache.delete(key)
|
249
249
|
true
|
250
250
|
rescue Memcached::NotFound
|
251
251
|
false
|
@@ -296,6 +296,10 @@ module ActiveSupport
|
|
296
296
|
value
|
297
297
|
end
|
298
298
|
|
299
|
+
def normalize_key(key)
|
300
|
+
escape_and_normalize(expanded_key(key))
|
301
|
+
end
|
302
|
+
|
299
303
|
def escape_and_normalize(key)
|
300
304
|
key = key.to_s.force_encoding("BINARY").gsub(ESCAPE_KEY_CHARS) { |match| "%#{match.getbyte(0).to_s(16).upcase}" }
|
301
305
|
key_length = key.length
|
data/lib/memcached/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libmemcached_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Cocchi-Perrier
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2016-03-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: memcached
|