diff --git a/doc/commands.json b/doc/commands.json index 23c3c23..62869fe 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -200,6 +200,11 @@ "group": "List", "readonly": true }, + "LTRIM": { + "arguments": "key start stop", + "group": "List", + "readonly": false + }, "LTTL": { "arguments": "key", "group": "List", diff --git a/doc/commands.md b/doc/commands.md index 772bd81..aac2a4b 100644 --- a/doc/commands.md +++ b/doc/commands.md @@ -75,6 +75,7 @@ Most of the Ledisdb's commands are the same as Redis's, you can see the redis co - [LMCLEAR key [key ...]](#lmclear-key-key-) - [LEXPIRE key seconds](#lexpire-key-seconds) - [LEXPIREAT key timestamp](#lexpireat-key-timestamp) + - [LTRIM key start stop](#ltrim-key-start-stop) - [LTTL key](#lttl-key) - [LPERSIST key](#lpersist-key) - [LDUMP key](#ldump-key) @@ -1215,6 +1216,26 @@ ledis> LTTL a ledis> ``` +### LTRIM key start stop +Trims the list stored at key. Only the elements in the specified range [start, stop] remain. + +**Return value** + +Simple string reply: OK or error msg. + +**Examples** + +``` +ledis> RPUSH a 1 2 3 4 5 +(integer) 1 +ledis> LTRIM a 2 -1 +OK +ledis> LRANGE a 0 -1 +1) "3" +2) "4" +3) "5" +``` + ### LTTL key Returns the remaining time to live of a key that has a timeout. If the key was not set a timeout, `-1` returns.