LPUSH key string
Add the string value to the head (RPUSH) or tail (LPUSH) of the list stored at the key. If the key does not exist an empty list is created just before the append operation.
Note: If the key exists but is not a List an error is returned.
TIME COMPLEXITY: O(1)
RETURN VALUE: Status code reply
Syntax:
LPUSH KEY_NAME VALUE
Example 1: When the key is of List
redis:6379> LPUSH myredisList 1200(integer) 1
Output
1
Example 2: When the key is not a list
redis:6379> SET rediKey 100"OK"redis:6379> LPUSH rediKey 200(error) WRONGTYPE Operation against a keyholding the wrong kind of value
Output
(error) WRONGTYPE Operation against a key holding the wrong kind of value
No comments:
Post a Comment