dalli 5.2.5 → 5.2.6
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/CHANGELOG.md +7 -0
- data/lib/dalli/protocol/meta.rb +12 -2
- data/lib/dalli/protocol/request_formatter.rb +22 -3
- data/lib/dalli/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: db76345a60e108cc8a1aa4f39adae0e657b200b4e3f17f7196702776c1ff8bc4
|
|
4
|
+
data.tar.gz: eb643908bb2aa3654f2d7c82bcce21fa82159931e162cdf17bd79d9fe40b2ed0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e5d227f5b4e7fda6e35907f0d94b74fcd528d0c203ce6a7c5b01ab33e2908fe78147c70df8661eedbc2b82f1024b4c89bb890fc0418745150c379805f87afea2
|
|
7
|
+
data.tar.gz: dbb2e3d7bb7b1c852a8c0d8b359f1621d0aa0f3ef32dbe1ca449e384325a929e0db6ba893357195e284c84162ce3ae4a1ce39e9f86b5b1bfde149a3725ae3a45
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ Dalli Changelog
|
|
|
4
4
|
Unreleased
|
|
5
5
|
==========
|
|
6
6
|
|
|
7
|
+
5.2.6
|
|
8
|
+
==========
|
|
9
|
+
|
|
10
|
+
Bug fixes:
|
|
11
|
+
|
|
12
|
+
- Raw values in an encoding that isn't ASCII-compatible, such as UTF-16, raised `Encoding::CompatibilityError` from `set`, `add`, `replace`, `append`, `prepend` and `set_multi`, as did a single-server `set_multi` mixing non-ASCII UTF-8 values with binary ones (such as raw Strings of both kinds, or with a JSON serializer, a value containing `é` next to a compressed one). A `p_token` or `l_token` with non-ASCII characters, such as `é`, did the same for any binary value, including every Marshal-serialized one. The error also closed the connection, so in a `quiet` block, or within one server's part of a multi-server `set_multi`, writes buffered before it were silently lost. Values are now sent as their bytes, which is what memcached stores (#1269)
|
|
13
|
+
|
|
7
14
|
5.2.5
|
|
8
15
|
==========
|
|
9
16
|
|
data/lib/dalli/protocol/meta.rb
CHANGED
|
@@ -167,7 +167,7 @@ module Dalli
|
|
|
167
167
|
ttl: ttl, mode: mode, quiet: quiet,
|
|
168
168
|
**routing_token_kwargs(options))
|
|
169
169
|
end
|
|
170
|
-
write(
|
|
170
|
+
write(request_with_value(req, value))
|
|
171
171
|
finish_write(quiet)
|
|
172
172
|
end
|
|
173
173
|
# rubocop:enable Metrics/ParameterLists
|
|
@@ -188,10 +188,20 @@ module Dalli
|
|
|
188
188
|
req = RequestFormatter.meta_set(key: key, value: value,
|
|
189
189
|
cas: cas, ttl: ttl, mode: mode, quiet: quiet?,
|
|
190
190
|
**routing_token_kwargs(options))
|
|
191
|
-
write(
|
|
191
|
+
write(request_with_value(req, value))
|
|
192
192
|
finish_write(quiet?)
|
|
193
193
|
end
|
|
194
194
|
|
|
195
|
+
# Ruby refuses to join Strings whose encodings clash, such as a raw
|
|
196
|
+
# UTF-16 value, or a routing token with non-ASCII characters next to a
|
|
197
|
+
# binary value. memcached stores bytes, so join the bytes then.
|
|
198
|
+
# Joining the Strings first keeps the common case free of extra checks.
|
|
199
|
+
def request_with_value(req, value)
|
|
200
|
+
"#{req}#{value}#{TERMINATOR}"
|
|
201
|
+
rescue Encoding::CompatibilityError
|
|
202
|
+
"#{req.b}#{value.b}#{TERMINATOR}"
|
|
203
|
+
end
|
|
204
|
+
|
|
195
205
|
# Delete Commands
|
|
196
206
|
#
|
|
197
207
|
# `options` supports the meta-delete keys :invalidate, :tombstone_ttl and
|
|
@@ -120,8 +120,9 @@ module Dalli
|
|
|
120
120
|
|
|
121
121
|
def multi_meta_set(entries, ttl: nil, p_token: nil, l_token: nil)
|
|
122
122
|
# Routing tokens apply to every entry in the batch, so the suffix is
|
|
123
|
-
# built once rather than per entry.
|
|
124
|
-
|
|
123
|
+
# built once rather than per entry. It's binary, like the buffer, so
|
|
124
|
+
# a token with non-ASCII characters doesn't turn the buffer UTF-8.
|
|
125
|
+
token_suffix = routing_tokens(p_token: p_token, l_token: l_token).b
|
|
125
126
|
ttl = integer_flag(:ttl, ttl) if ttl
|
|
126
127
|
|
|
127
128
|
buffer = ''.b
|
|
@@ -136,11 +137,29 @@ module Dalli
|
|
|
136
137
|
buffer << ' b' if base64
|
|
137
138
|
buffer << " F#{bitflags}" if bitflags
|
|
138
139
|
buffer << " T#{ttl}" if ttl
|
|
139
|
-
buffer << ' MS q' << token_suffix << TERMINATOR
|
|
140
|
+
buffer << ' MS q' << token_suffix << TERMINATOR
|
|
141
|
+
append_bytes(buffer, value)
|
|
142
|
+
buffer << TERMINATOR
|
|
140
143
|
end
|
|
141
144
|
buffer << META_NOOP
|
|
142
145
|
end
|
|
143
146
|
|
|
147
|
+
# Values are appended as bytes. One batch can hold UTF-8 and binary
|
|
148
|
+
# values, which String#<< refuses to combine, and a raw value can be in
|
|
149
|
+
# an encoding that isn't ASCII-compatible, such as UTF-16.
|
|
150
|
+
# Don't chain on the result: TruffleRuby's append_as_bytes returns its
|
|
151
|
+
# arguments rather than the buffer.
|
|
152
|
+
if String.method_defined?(:append_as_bytes)
|
|
153
|
+
def append_bytes(buffer, value)
|
|
154
|
+
buffer.append_as_bytes(value)
|
|
155
|
+
end
|
|
156
|
+
else
|
|
157
|
+
def append_bytes(buffer, value)
|
|
158
|
+
buffer << (value.encoding == Encoding::BINARY ? value : value.b)
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
private :append_bytes
|
|
162
|
+
|
|
144
163
|
# Thundering herd protection flag:
|
|
145
164
|
# - stale (I flag): Instead of deleting the item, mark it as stale. Other clients
|
|
146
165
|
# using N/R flags will see the X flag and know the item is being regenerated.
|
data/lib/dalli/version.rb
CHANGED