gpt4 book ai didi

java - Redis是否只允许字符串表示而不允许数值

转载 作者:IT王子 更新时间:2023-10-29 05:55:31 26 4
gpt4 key购买 nike

我在这里的研究得到了不同的答案。

  • 有人可以验证 Redis 服务器只能存储任何数值的表示形式吗?

  • 例如,如果我在 lpush 中使用带有 double 类型的 Java 客户端 (Jedis),在发送到 Redis 之前是否需要将其转换为等效的字符串类型?

  • 或者有什么方法可以发送一个实际的数字类型,比如 double ?如果是这样,是否有关于如何完成此操作的示例代码?

谢谢

最佳答案

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.

还有绝地武士;查看源代码,我认为它不支持除字符串以外的任何内容

关于java - Redis是否只允许字符串表示而不允许数值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32389158/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com