Latest web development tutorials

Redis comando LSET

Redis lista (Lista)

Redis LSET para ajustar el valor del elemento por el índice.

Cuando el parámetro de índice está fuera de rango, o una lista vacía LSET, se devuelve un error.

Para obtener más información sobre el tema en la lista, consulte el comando LINDEX .

gramática

Redis LSET sintaxis del comando básico es el siguiente:

redis 127.0.0.1:6379> LSET KEY_NAME INDEX VALUE

versiones disponibles

> = 1.0.0

Valor de retorno

Operación retorno exitoso bien, de lo contrario, devuelve un mensaje de error.

Ejemplos

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"

Redis lista (Lista)