Redis command o...login
Redis command operation Chinese manual
author:php.cn  update time:2022-04-12 14:07:28

Redis string (String)


Redis string data type related commands are used to manage redis string values. The basic syntax is as follows:

Syntax

redis 127.0.0.1:6379> COMMAND KEY_NAME

Example

redis 127.0. 0.1:6379> SET w3ckey redis OK redis 127.0.0.1:6379> GET w3ckey "redis"

In the above example we used the SET and GET commands, and the key is w3ckey.


Redis string commands

The following table lists the commonly used redis string commands:

Serial numberCommand and description
1SET key value
Set the specified key The value of
2GET key
Get the value of the specified key.
3GETRANGE key start end
Return the sub-characters of the string value in key
4GETSET key value
Set the value of the given key to value and return the old value of the key.
5GETBIT key offset
Get the bit at the specified offset for the string value stored in key.
6MGET key1 [key2..]
Get the values ​​of all (one or more) given keys.
7SETBIT key offset value
Set or clear the bit at the specified offset for the string value stored in key.
8SETEX key seconds value
Associate the value value to key and set the expiration time of key to seconds (in seconds).
9SETNX key value
Set the value of key only when the key does not exist.
10SETRANGE key offset value
Use the value parameter to overwrite the string value stored in the given key, starting from the offset offset.
11STRLEN key
Returns the length of the string value stored in key.
12MSET key value [key value ...]
Set one or more key-value pairs at the same time.
13MSETNX key value [key value ...]
Set one or more key-value pairs simultaneously, if and only if all given None of the keys exist.
14PSETEX key milliseconds value
This command is similar to the SETEX command, but it sets the key's survival time in milliseconds, not like the SETEX command That way, in seconds.
15INCR key
Increase the numerical value stored in key by one.
16INCRBY key increment
Add the given increment to the value stored in key.
17INCRBYFLOAT key increment
Add the given floating point increment value (increment) to the value stored in key.
18DECR key
Decrease the numeric value stored in key by one.
19DECRBY key decrement
The value stored in key minus the given decrement value (decrement).
20APPEND key value
If key already exists and is a string, the APPEND command appends value to the end of the original value of key.

For more commands, please refer to: http://redis.readthedocs.org/en/latest/

php.cn