Reputation: 2022
I am using an API to fetch all kinds of data from Redis and perform different operations on them. In case of bitmaps and HLLs, I am not able to do this since they are both stored as strings on and running get on keys belonging to these data structures I am not able to differentiate between the returned values whether they are from normal string keys or HLLs or bitmaps.
Is there a redis command to identify the underlying data structure to which data structure the returned value belongs to?
Upvotes: 1
Views: 173
Reputation: 16394
No, for bitmaps and HLLs there's no way to get that information, because redis does not store it. Any given string could conceivably be just some string, or a bitmap. Every string is also a valid bitmap, and every bitmap can be interpreted as a string.
Of course you could hack together some heuristics, but those are bound to fail, and obviously terribly ugly.
If you have any control over the data definition, you can encode such information in the KEY.
(Previous, uninformed answer follows)
Yes, there's the TYPE
command:
redis> SET key1 "value"
"OK"
redis> LPUSH key2 "value"
(integer) 1
redis> SADD key3 "value"
(integer) 1
redis> TYPE key1
"string"
redis> TYPE key2
"list"
redis> TYPE key3
"set"
Upvotes: 2