Redis LINSERT command inserts the value in the list stored at the key either before or after the reference value pivot. When the key does not exist, it is considered an empty list and no operation is performed. An error is returned when the key exists but does not hold a list value.
Return Value
Integer reply, the length of the list after the insert operation, or -1 when the value pivot was not found.
Syntax
Following is the basic syntax of Redis LINSERT command.
redis 127.0.0.1:6379> LINSERT KEY_NAME BEFORE EXISTING_VALUE NEW_VALUE
Example
redis 127.0.0.1:6379> RPUSH list1 "foo" (integer) 1 redis 127.0.0.1:6379> RPUSH list1 "bar" (integer) 2 redis 127.0.0.1:6379> LINSERT list1 BEFORE "bar" "Yes" (integer) 3 redis 127.0.0.1:6379> LRANGE mylist 0 -1 1) "foo" 2) "Yes" 3) "bar"
Pingback: Redis - Lists - Adglob Infosystem Pvt Ltd
Looking forward to reading more. Great blog article.Really looking forward to read more. Much obliged.