Redis's List is different from C#'s List,but similar with C#'s LinkedList.sometimes I confuse with them.I expect
that you won't mix them and have a clear mind of them.
There are 17 commands we can use in List.
Push and pop are the base opreation of the linkediist,either as Redis's List.When we want to store the
list,lpush and rpush can help us to save the data.Both of them can save one or more values to the key.Now
I add element 11 to the key named list-1,then add element 12 and 13 to this key.Here're the commands and result.
The code demonstrated above push the element from left to the right.As all we kNow,linkedlist has anonther
way to push the elements.rpush is the another way.For example,I push the same elements to the key named list-2.
Taking the following code and result.
By using those two commands to store the data,we don't kNow the Difference between them apparently.But when
you select all of the elements,you will find out something.Using lrange can make us kNow the elements in the list.
The next picture explain the result clearly.You can combine the linkedlist's feature to think about the result.
We also can insert an element before or after another element.Redis provides a command for us.For an instance,
I insert 90 before 12 on list-1,and insert 80 after 12.You will get the following result.
Sometimes we may want to kNow how many elements in the list?Just as the length of a string.We use llen to
get the length of the list.
The next time I will show you how to remove the elements from the list.There are three commands can help
us to remove elements.
lpop will remove the leftmost element from the list.And the client will return the removed element.
rpop will remove the rightmost element from the list.And the client will return the removed element as well.
lrem will remove the count occurrences of elements equal to value.If count > 0,it will remove elements moving
from head to tail.If count < 0,it will remove elements moving from tail to head.If count = 0,it will remove all elements
equal to value.