I'm storing foos and bars (both hashes), with each foo pointing to a bar. To get bar fields from a list of foos, I would SORT foo GET foo:*->bar and then do O(N) HGETs. (N being the number of items.)

The O(N) HGETs could be removed if it were possible to do something like SORT foo GET bar:{foo:*->bar}->field.

A workaround would be to store bar's field in foo and using SORT foo GET foo:*->bar_field, but that would require adding O(M) HSETs when updating bar's field. (M being the number of hashes pointing to the hash being written.) It would also require more memory to store the field in each foo.

Being able to nest hash lookups would remove the O(N) HGETs without adding O(M) HSETs.

Comment From: ljluestc

-- Update the bar hash and retrieve the foo hashes pointing to it
HSET bar:123 field value
SMEMBERS foo:bar:123

-- Iterate over the foo hashes and update the bar_field
SADD foo:bar:123 foo:1 foo:2 foo:3
HSET foo:1 bar_field value
HSET foo:2 bar_field value
HSET foo:3 bar_field value

-- Retrieve the bar_field from multiple foo hashes using SORT and GET
SORT foo:1 foo:2 foo:3 GET #->bar_field