Shabin Hashim Shabin Hashim - 1 year ago 151
Java Question

Redis storing list inside hash

I have to store some machine details in redis. As there are many different machines i am planning to use the below structure

server1 => {name => s1, cpu=>80}
server2 => {name => s2, cpu=>40}

I need to store more than one value against the key CPU. Also i need to maintain only the last 10 values in the list of values against cpu

1) How can i store a list against the key inside the hash?

2) I read about ltrim. But it accepts a key. How can i do a ltrim for key cpu inside server1?

I am using jedis.

Answer Source

Redis' data structures cannot be nested inside other data structures, so storing a List inside a Hash is not possible. Instead, use different keys for your servers' CPU values (e.g. server1:cpu).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download