Redis是否只允许字符串表示而不允许数值
Does Redis only allow string representation but not numeric value
我在这里的研究得到了不同的答案。
谁能验证Redis Server只能存储任何数值的表示形式?
例如,如果我在 lpush 中使用一个带有 double 类型的 Java 客户端(Jedis),在发送到 Redis 之前是否需要将其转换为等价的字符串类型?
或者有什么方法可以发送像双精度数这样的实际数字类型?如果是这样,是否有关于如何完成此操作的示例代码?
谢谢
Redis 将所有内容存储在字符串或其字符串表示形式中。
甚至像 INCR 这样的函数也通过首先将其解析为 INTEGER 然后执行操作
来工作
Note: this is a string operation because Redis does not have a dedicated integer type. The string stored at the key is interpreted as a base-10 64 bit signed integer to execute the operation.
Redis stores integers in their integer representation, so for string values that actually hold an integer, there is no overhead for storing the string representation of the integer.
和w.r.t绝地武士;查看源代码,我认为它不支持除字符串以外的任何其他内容
如果您使用 JSON 编解码器,双数可以存储为字符串,但它也可以存储为 Kryo、CBOR、MsgPack 编解码器使用的二进制格式,这些编解码器受基于 Redis 的框架支持 Java - Redisson.
我在这里的研究得到了不同的答案。
谁能验证Redis Server只能存储任何数值的表示形式?
例如,如果我在 lpush 中使用一个带有 double 类型的 Java 客户端(Jedis),在发送到 Redis 之前是否需要将其转换为等价的字符串类型?
或者有什么方法可以发送像双精度数这样的实际数字类型?如果是这样,是否有关于如何完成此操作的示例代码?
谢谢
Redis 将所有内容存储在字符串或其字符串表示形式中。 甚至像 INCR 这样的函数也通过首先将其解析为 INTEGER 然后执行操作
来工作Note: this is a string operation because Redis does not have a dedicated integer type. The string stored at the key is interpreted as a base-10 64 bit signed integer to execute the operation.
Redis stores integers in their integer representation, so for string values that actually hold an integer, there is no overhead for storing the string representation of the integer.
和w.r.t绝地武士;查看源代码,我认为它不支持除字符串以外的任何其他内容
如果您使用 JSON 编解码器,双数可以存储为字符串,但它也可以存储为 Kryo、CBOR、MsgPack 编解码器使用的二进制格式,这些编解码器受基于 Redis 的框架支持 Java - Redisson.