heavy rocker dude
heavy rocker dude

Reputation: 2301

Does Redis only allow string representation but not numeric value

I am getting mixed answers on my research here.

Thanks

Upvotes: 18

Views: 6731

Answers (2)

Nikita Koksharov
Nikita Koksharov

Reputation: 10803

Double numbers could be stored as string if you're using JSON codecs, but it also could be stored in binary format used by Kryo, CBOR, MsgPack codecs which are supported by Redis based framework for Java - Redisson.

Upvotes: 0

Basit Anwer
Basit Anwer

Reputation: 6870

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

Upvotes: 21

Related Questions