
- Redis Basics
- Redis - Home
- Redis - Overview
- Redis - Environment
- Redis - Configuration
- Redis - Data types
- Redis Commands
- Redis - Commands
- Redis - Keys
- Redis - Strings
- Redis - Hashes
- Redis - Lists
- Redis - Sets
- Redis - Sorted Sets
- Redis - HyperLogLog
- Redis - Publish Subscribe
- Redis - Transactions
- Redis - Scripting
- Redis - Connections
- Redis - Server
- Redis Advanced
- Redis - Backup
- Redis - Security
- Redis - Benchmarks
- Redis - Client Connection
- Redis - Pipelining
- Redis - Partitioning
- Redis - Java
- Redis - Php
- Redis Useful Resources
- Redis - Quick Guide
- Redis - Useful Resources
- Redis - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Redis - List Linsert Command
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"
redis_lists.htm
Advertisements