Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Redis only allow string representation but not numeric value

Tags:

java

redis

jedis

I am getting mixed answers on my research here.

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

  • 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?

Thanks

like image 346
heavy rocker dude Avatar asked Sep 04 '15 02:09

heavy rocker dude


People also ask

Does Redis only store string?

In Redis, we have the advantage of storing both strings and collections of strings as values. A string value cannot exceed 512 MB of text or binary data. However, it can store any type of data, like text, integers, floats, videos, images, and audio files.

Does Redis support integer?

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.


1 Answers

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

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.

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

like image 188
Basit Anwer Avatar answered Oct 25 '22 06:10

Basit Anwer