I want to use a hash of hash (nested hash). For example,
{Key 1 ->
{Subkey 1 -> {Value1, Value2...},
Subkey 2 -> {Value1, Value2...},
.
.
Subkey n -> {Value1, Value2...}
}
Key 2 -> {...}
.
.
Key n -> {...}
}
Tell me how I can define this structure in redis and also how to access these values. I am trying to use this on ruby.
you can't use nested hash in redis, but in the kind of situation you are asking you can use two hashes, one for key to subkey and the other one for subkey to your values.
If you just want to store and retrieve them and you don't need the hash functions in Redis, you can just serialize the subhashes (e.g. Marshal, JSON, YAML).
Otherwise consider a different key-value database, like MongoDB; or @whishky's answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With