Quantcast
Viewing latest article 1
Browse Latest Browse All 2

Answer by Vlad Cheremisin for How can I get customized value from Redis cache?

You can use hmget operation and specify fields what you need. Next example from official documentation:

redis> HSET myhash field1 "Hello"
(integer) 1
redis> HSET myhash field2 "World"
(integer) 1
redis> HMGET myhash field1 field2 nofield
1) "Hello"
2) "World"
3) (nil)

Edited: If you prefer use list it may look like this:

RPUSH mylist "name"
(integer) 1
redis> RPUSH mylist "age"
(integer) 2
redis> RPUSH mylist "DOB"
(integer) 3

Then you can use

LRANGE mylist 0 1
1) "name"
2) "age"

But if you need associate key with value for one object more elegant will be Hashes data structure


Viewing latest article 1
Browse Latest Browse All 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>