In Redis, to store an array of objects we should use hash for the object and add its key to a list:
HMSET concept:unique_id name "concept" ... LPUSH concepts concept:unique_id ...
I want to retrieve all hash values (or objects) in the list, but the list contains only hash keys so a two step command is necessary, right? This is how I'm doing in python:
def get_concepts(): list = r.lrange("concepts", 0, -1) pipe = r.pipeline() for key in list: pipe.hgetall(key) pipe.execute()
Is it necessary to iterate and fetch each individual item? Can it be more optimized?