English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
O Redis Lset define o valor do elemento através de um índice.
Retorna um erro quando o parâmetro de índice está fora do intervalo ou ao tentar LSET em uma lista vazia.
Para mais informações sobre os índices da lista, consulte Comando LINDEX.
A sintaxe básica do comando redis Lset é a seguinte:
redis 127.0.0.1:6379> LSET KEY_NAME INDEX VALUE
>= 1.0.0
A operação retorna "ok" com sucesso, caso contrário, retorna uma mensagem de erro.
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 "hello" (integer) 4 redis 127.0.0.1:6379> LSET mylist 0 "bar" OK redis 127.0.0.1:6379> LRANGE mylist 0 -1 1: "bar" 2) "hello" 3) "foo" 4) "hello"