How do i create a list of values using redis?
-
Redis lpush command: https://redis.io/commands/lpush
Redis lrange command: https://redis.io/commands/lrange
Redis rpush command: https://redis.io/commands/rpush
Redis linsert command: https://redis.io/commands/linsertTo create a list of values in redis use the lpush command
127.0.0.1:6379> lpush mysonglist "nowhere man" "help" (integer) 2
To display the list.
127.0.0.1:6379> lrange mysonglist 0 -1 1) "help" 2) "nowhere man"
Add entries to the right of the list.
127.0.0.1:6379> rpush mysonglist "norwegian wood" "let it be" (integer) 4 127.0.0.1:6379> lrange mysonglist 0 -1 1) "help" 2) "nowhere man" 3) "norwegian wood" 4) "let it be"
Add entries to the somewhere in a list, before or after an entry.
127.0.0.1:6379> linsert mysonglist before "norwegian wood" "In my life" (integer) 5 127.0.0.1:6379> lrange mysonglist 0 -1 1) "help" 2) "nowhere man" 3) "In my life" 4) "norwegian wood" 5) "let it be"
Pick out a particular element in the list.
127.0.0.1:6379> lindex mysonglist 3 "norwegian wood"
© Lightnetics 2024