From c49b632833442563351134e7e37c70f86a31d802 Mon Sep 17 00:00:00 2001 From: "David W. Dougherty" Date: Mon, 21 Oct 2024 12:15:26 -0700 Subject: [PATCH] DEV: fix attribute type examples on the protocol page --- content/develop/reference/protocol-spec.md | 40 ++++++++++++---------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/content/develop/reference/protocol-spec.md b/content/develop/reference/protocol-spec.md index e948cca11a..3b68eac509 100644 --- a/content/develop/reference/protocol-spec.md +++ b/content/develop/reference/protocol-spec.md @@ -537,20 +537,22 @@ The first element is a key, followed by the corresponding value, then the next k The attribute type is exactly like the Map type, but instead of a `%` character as the first byte, the `|` character is used. Attributes describe a dictionary exactly like the Map type. However the client should not consider such a dictionary part of the reply, but as auxiliary data that augments the reply. +Note: in the examples below, indentation is shown only for clarity; the additional whitespace would not be part of a real reply. + For example, newer versions of Redis may include the ability to report the popularity of keys for every executed command. The reply to the command `MGET a b` may be the following: - |1 - +key-popularity - %2 - $1 - a - ,0.1923 - $1 - b - ,0.0012 - *2 - :2039123 - :9543892 + |1\r\n + +key-popularity\r\n + %2\r\n + $1\r\n + a\r\n + ,0.1923\r\n + $1\r\n + b\r\n + ,0.0012\r\n + *2\r\n + :2039123\r\n + :9543892\r\n The actual reply to `MGET` is just the two item array `[2039123, 9543892]`. The returned attributes specify the popularity, or frequency of requests, given as floating point numbers ranging from `0.0` to `1.0`, of the keys mentioned in the original command. Note: the actual implementation in Redis may differ. @@ -569,13 +571,13 @@ When a client reads a reply and encounters an attribute type, it should read the Attributes can appear anywhere before a valid part of the protocol identifying a given type, and supply information only about the part of the reply that immediately follows. For example: - *3 - :1 - :2 - |1 - +ttl - :3600 - :3 + *3\r\n + :1\r\n + :2\r\n + |1\r\n + +ttl\r\n + :3600\r\n + :3\r\n In the above example the third element of the array has associated auxiliary information of `{ttl:3600}`. Note that it's not up to the client library to interpret the attributes, but it should pass them to the caller in a sensible way.