- 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
Redis - List Ltrim Command
Redis LTRIM command trims an existing list so that it contains only the specified range of elements. Both start and stop are zero-based indexes, where 0 is the first element of the list (the head), 1 the next element, and so on.
Return Value
String reply, OK.
Syntax
Following is the basic syntax of redis LTRIM command.
redis 127.0.0.1:6379> LTRIM KEY_NAME START STOP
Example
redis 127.0.0.1:6379> RPUSH mylist "hello" (integer) 1 redis 127.0.0.1:6379> RPUSH mylist "hello" (integer) 2 redis 127.0.0.1:6379> RPUSH mylist "foo" (integer) 3 redis 127.0.0.1:6379> RPUSH mylist "bar" (integer) 4 redis 127.0.0.1:6379> LTRIM mylist 1 -1 OK redis 127.0.0.1:6379> LRANGE mylist 0 -1 1) "hello" 2) "foo" 3) "bar"
redis_lists.htm
Advertisements