For example I have key structure entity:product:[id]
where id - is an integer [0-n]
So I can use this keys entity:product:*
but I don't how much load does this query to the redis server.
Another solution is
Create one list key that will store Ids of the entity:products.
RPUSH entity:products:ids 1 RPUSH entity:products:ids 2 RPUSH entity:products:ids 3 RPUSH entity:products:ids 4
And then (pseudo-code)
entityProducts = redis.LRANGE('entityLproducts:ids, 0, -1) foreach (entityProducts as id) { redis.GET('entity:product:' + id) }
What is the better way? What will be faster and what will do less load to the redis server?