I want to have a state and list for each identifier , my question is should i implement redis hash with state and list(custom list) for each identifier , or build a hash for state and list for queue and use identifier as name space, my point Is there any optimization or benefits from using redis list or i can use a custom one which will be inside the hash. To illustrate more :
'fw7qw8f6fqw7f' => { state: accpeted
my_list = [1 ,4]
}
or
state:fw7qw8f6fqw7f => state: accpeted
list:fw7qw8f6fqw7f => [1,4]
Both of them work but i ask in terms of efficiency which is better
It depends...
If you need to do list operations, e.g. llen, lpush, lpop, you must store the list as a Redis LIST. If you don't need to do these operations, you can store it as a HASH field, i.e. store the list as a string.
The LIST solution costs more memory than the HASH solution. Especially, when your list is small, Redis has some magic encoding to largely reduce memory usage.
Also, with the HASH solution, when you need to get the whole list back, it should be more time efficient than the LIST solution. The latter solution needs to iterate the list one by one, while the former just returns the list as a string.