diff --git a/doc/commands.json b/doc/commands.json index 62869fe..87bb849 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -200,6 +200,11 @@ "group": "List", "readonly": true }, + "LSET": { + "arguments": "key index value", + "group": "List", + "readonly": false + }, "LTRIM": { "arguments": "key start stop", "group": "List", diff --git a/doc/commands.md b/doc/commands.md index ba2f0a3..2bc8aa5 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) + - [LSET key index value](#lset-key-index-value) - [LTRIM key start stop](#ltrim-key-start-stop) - [LTTL key](#lttl-key) - [LPERSIST key](#lpersist-key) @@ -1031,6 +1032,28 @@ ledis> LPOP a one ``` +### LSET key index value + +Sets a value to a list element according the index offset left of the list. + +**Return value** + +Return OK or error message. + +**Examples** + +``` +ledis> RPUSH a 'one' +(integer) 1 +ledis> RPUSH a 'two' +(integer) 2 +ledis> LSET a 1 'three' +OK +ledis> LRANGE a 0 10 +1) "two" +2) "three" +``` + ### LRANGE key start stop Returns the specified elements of the list stored at key. The offsets start and stop are zero-based indexes, with 0 being the first element of the list (the head of the list), `1` being the next element and so on.