Redis是否仅允许字符串表示,但不允许数字值 [英] Does Redis only allow string representation but not numeric value

查看:220
本文介绍了Redis是否仅允许字符串表示,但不允许数字值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里的研究得到的答案很复杂。

I am getting mixed answers on my research here.


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

  • Can someone verify that the Redis Server can only store representation of any numerical values?

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

For instance, if I use a Java client (Jedis) with a double type in lpush, do I need to convert it to the equivalent of a string type before sending to Redis?

或者有没有办法可以发送实际的数字类型,如双?如果是的话,是否有任何关于如何实现此目的的示例代码?

Or is there a way to I can send over an actual numeric type like a double? If so, is there any example code on how to accomplish this?

谢谢

推荐答案

Redis将所有内容存储在字符串或其字符串表示中。
甚至像 INCR 这样的函数首先将其解析为INTEGER然后执行操作

Redis stores everything in string or in its string representation. Even functions like INCR work by first parsing it into INTEGER then performing the operation


注意:这是一个字符串操作,因为Redis没有专用的整数类型。存储在键中的字符串被解释为base-10 64位有符号整数以执行操作。

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以整数表示形式存储整数,因此对于字符串值,实际上持有一个整数,没有用于存储整数的字符串表示的开销。

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.

和wrt Jedis;查看源代码我不认为它支持除字符串以外的任何其他内容

And w.r.t Jedis; looking at the source i don't think it supports anything else other than strings

这篇关于Redis是否仅允许字符串表示,但不允许数字值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆