English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

String (String) Redis

The commands related to the Redis string data type are used to manage Redis string values, with basic syntax as follows:

Syntax

redis 127.0.0.1:6379> COMMAND KEY_NAME

Online example

redis 127.0.0.1:6379> SET w3codeboxkey redis
OK
redis 127.0.0.1:6379> GET w3codeboxkey
"redis"

In the above examples, we used SET and GET Command, key as w3codeboxkey.

Redis string command

The following table lists common redis string commands:

Serial numberCommand and description
1SET key value
Set the value of the specified key
2GET key
Get the value of the specified key.
3GETRANGE key start end
Return the substring of the string value in key.
4GETSET key value
Set the value of the given key to value and return the old value (old value) of key.
5GETBIT key offset
Get the bit at the specified offset of the string value stored at key.
6MGET key1 [key2..]
Get the value of all (one or more) given keys.
7SETBIT key offset value
Set or clear the bit at the specified offset of the string value stored at key.
8SETEX key seconds value
Associate the value value with key and set the expiration time of key to seconds (in seconds).
9SETNX key value
Set the value of key only if the key does not exist.
10SETRANGE key offset value
Use the value parameter to overwrite the string value stored at the given key, starting from the offset offset.
11STRLEN key
Retorna o comprimento da string armazenada pelo key.
12Definir um ou mais keys ao mesmo tempo
Definir um ou mais keys ao mesmo tempo-value se todos os keys fornecidos não existirem.
13MSETNX key value [key value ...]
Definir um ou mais keys ao mesmo tempo-value se todos os keys fornecidos não existirem.
14PSETEX key milliseconds value
Este comando é semelhante ao comando SETEX, mas define o tempo de vida do key em milissegundos, ao invés de segundos como o comando SETEX.
15INCR key
Incrementa o valor armazenado pelo key em um.
16INCRBY key increment
Adiciona o valor increment ao valor armazenado pelo key.
17INCRBYFLOAT key increment
Adiciona o valor flutuante increment ao valor armazenado pelo key.
18DECR key
Diminui o valor armazenado pelo key em um.
19DECRBY key decrement
Subtrai o valor decremento do valor armazenado pelo key.
20APPEND key value
Se o key já existir e for uma string, o comando APPEND adicionará o valor especificado ao final do valor original do key.

Mais comandos, consulte:https://redis.io/comandos