Storing Lists in Redis: Insertion Commands
Let’s look at the commands used to insert Lists in the Redis database.
We'll cover the following...
As well as storing Strings in Redis, we can also store Lists. The Redis database internally stores List as a linked list. This linked list has a head
and tail
. Whenever we insert a new element, we can insert it either at the head
or tail
. The ‘head’ of the list is considered as the left-most element of the list and the ‘tail’ is considered as right-most element of the list.
Let’s look at some of the commands that are used to handle the List in the Redis database. We need to store a list of all the companies which build cars. We will store the list in a key, called cars. If a new company arrives then it is added to the list. If a company stops producing cars, then it is removed from the list. We are going to maintain this list in Redis. ...