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 number | Command and description |
---|---|
1 | SET key value Set the specified key The value of |
2 | GET key Get the value of the specified key. |
3 | GETRANGE key start end Return the sub-characters of the string value in key |
4 | GETSET key value Set the value of the given key to value and return the old value of the key. |
5 | GETBIT key offset Get the bit at the specified offset for the string value stored in key. |
6 | MGET key1 [key2..] Get the values of all (one or more) given keys. |
7 | SETBIT key offset value Set or clear the bit at the specified offset for the string value stored in key. |
8 | SETEX key seconds value Associate the value value to key and set the expiration time of key to seconds (in seconds). |
9 | SETNX key value Set the value of key only when the key does not exist. |
10 | SETRANGE key offset value Use the value parameter to overwrite the string value stored in the given key, starting from the offset offset. |
11 | STRLEN key Returns the length of the string value stored in key. |
12 | MSET key value [key value ...] Set one or more key-value pairs at the same time. |
13 | MSETNX key value [key value ...] Set one or more key-value pairs simultaneously, if and only if all given None of the keys exist. |
14 | PSETEX 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. |
15 | INCR key Increase the numerical value stored in key by one. |
16 | INCRBY key increment Add the given increment to the value stored in key. |
17 | INCRBYFLOAT key increment Add the given floating point increment value (increment) to the value stored in key. |
18 | DECR key Decrease the numeric value stored in key by one. |
19 | DECRBY key decrement The value stored in key minus the given decrement value (decrement). |
20 | APPEND 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/