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..ba2f0a3 100644 --- a/doc/commands.md +++ b/doc/commands.md @@ -48,7 +48,7 @@ Most of the Ledisdb's commands are the same as Redis's, you can see the redis co - [HLEN key](#hlen-key) - [HMGET key field [field ...]](#hmget-key-field-field-) - [HMSET key field value [field value ...]](#hmset-key-field-value-field-value-) - - [HSCAN key cursor [MATCH match] [COUNT count] [ASC|DESC]](#hscan-key-cursor-match-match-count-count-asc|desc) + - [HSCAN key cursor [MATCH match] [COUNT count] [ASC|DESC]](#hscan-key-cursor-match-match-count-count-ascdesc) - [HSET key field value](#hset-key-field-value) - [HVALS key](#hvals-key) - [HCLEAR key](#hclear-key) @@ -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) @@ -89,7 +90,7 @@ Most of the Ledisdb's commands are the same as Redis's, you can see the redis co - [SISMEMBER key member](#sismember--key-member) - [SMEMBERS key](#smembers-key) - [SREM key member [member ...]](#srem--key-member-member-) - - [SSCAN key cursor [MATCH match] [COUNT count] [ASC|DESC]](#sscan-key-cursor-match-match-count-count-asc|desc) + - [SSCAN key cursor [MATCH match] [COUNT & count] [ASC|DESC]](#sscan-key-cursor-match-match-count--count-ascdesc) - [SUNION key [key ...]](#sunion-key-key-) - [SUNIONSTORE destination key [key]](#sunionstore-destination-key-key) - [SCLEAR key](#sclear-key) @@ -114,30 +115,30 @@ Most of the Ledisdb's commands are the same as Redis's, you can see the redis co - [ZREVRANGE key start stop [WITHSCORES]](#zrevrange-key-start-stop-withscores) - [ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count]](#zrevrangebyscore--key-max-min-withscores-limit-offset-count) - [ZREVRANK key member](#zrevrank-key-member) - - [ZSCAN key cursor [MATCH match] [COUNT count] [ASC|DESC]](#zscan-key-cursor-match-match-count-count-asc|desc) - [ZSCORE key member](#zscore-key-member) + - [ZSCAN key cursor [MATCH match] [COUNT count] [ASC|DESC]](#zscan-key-cursor-match-match-count-count-ascdesc) - [ZCLEAR key](#zclear-key) - [ZMCLEAR key [key ...]](#zmclear-key-key-) - [ZEXPIRE key seconds](#zexpire-key-seconds) - [ZEXPIREAT key timestamp](#zexpireat-key-timestamp) - [ZTTL key](#zttl-key) - [ZPERSIST key](#zpersist-key) - - [ZUNIONSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX]](#zunionstore-destination-numkeys-key-key--weights-weight-weight--aggregate-sum|min|max) - - [ZINTERSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX]](#zinterstore-destination-numkeys-key-key--weights-weight-weight--aggregate-sum|min|max) + - [ZUNIONSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX]](#zunionstore-destination-numkeys-key-key--weights-weight-weight--aggregate-summinmax) + - [ZINTERSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX]](#zinterstore-destination-numkeys-key-key--weights-weight-weight--aggregate-summinmax) - [ZRANGEBYLEX key min max [LIMIT offset count]](#zrangebylex-key-min-max-limit-offset-count) - [ZREMRANGEBYLEX key min max](#zremrangebylex-key-min-max) - [ZLEXCOUNT key min max](#zlexcount-key-min-max) - [ZDUMP key](#zdump-key) - [ZKEYEXISTS key](#zkeyexists-key) - [Scan](#scan) - - [XSCAN type cursor [MATCH match] [COUNT count] [ASC|DESC]](#xscan-type-cursor-match-match-count-count-asc|desc) - - [XHSCAN key cursor [MATCH match] [COUNT count] [ASC|DESC]](#xhscan-key-cursor-match-match-count-count-asc|desc) - - [XSSCAN key cursor [MATCH match] [COUNT count] [ASC|DESC]](#xsscan-key-cursor-match-match-count-count-asc|desc) - - [XZSCAN key cursor [MATCH match] [COUNT count] [ASC|DESC]](#xzscan-key-cursor-match-match-count-count-asc|desc) + - [XSCAN type cursor [MATCH match] [COUNT count] [ASC|DESC]](#xscan-type-cursor-match-match-count-count-ascdesc) + - [XHSCAN key cursor [MATCH match] [COUNT count] [ASC|DESC]](#xhscan-key-cursor-match-match-count-count-ascdesc) + - [XSSCAN key cursor [MATCH match] [COUNT count] [ASC|DESC]](#xsscan-key-cursor-match-match-count-count-ascdesc) + - [XZSCAN key cursor [MATCH match] [COUNT count] [ASC|DESC]](#xzscan-key-cursor-match-match-count-count-ascdesc) - [Sort](#sort) - - [XLSORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination]](#xlsort-key-by-pattern-limit-offset-count-get-pattern-get-pattern--asc|desc-alpha-store-destination) - - [XSSORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination]](#xssort-key-by-pattern-limit-offset-count-get-pattern-get-pattern--asc|desc-alpha-store-destination) - - [XZSORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination]](#xzsort-key-by-pattern-limit-offset-count-get-pattern-get-pattern--asc|desc-alpha-store-destination) + - [XLSORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination]](#xlsort-key-by-pattern-limit-offset-count-get-pattern-get-pattern--ascdesc-alpha-store-destination) + - [XSSORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination]](#xssort-key-by-pattern-limit-offset-count-get-pattern-get-pattern--ascdesc-alpha-store-destination) + - [XZSORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination]](#xzsort-key-by-pattern-limit-offset-count-get-pattern-get-pattern--ascdesc-alpha-store-destination) - [Replication](#replication) - [SLAVEOF host port [RESTART] [READONLY]](#slaveof-host-port-restart-readonly) - [FULLSYNC [NEW]](#fullsync-new) @@ -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.