Home » Redis Strings

Redis String

Redis strings commands are used to manage string values in Redis. See the syntax for using Redis string commands.

Syntax:

Example

Here, SET and GET are commands and “tutoraspire” is key.

Redis String 1


Redis Strings Commands

Following is a list of some basic commands which are used to manage strings in Redis.

Index Command Description
1 SET key value This command is used to set the value at the specified key.
2 GET key This command is used to retrieve the value of a key.
3 GETRANGE key start end This command is used to get a substring of the string stored at a key.
4 GETSET key value This command is used to set the string value of a key and return its old value.
5 GETBIT key offset This command is used to return the bit value at the offset in the string value stored at the key.
6 MGET key1 [key2..] This command is used to get the values of all the given keys
7 SETBIT key offset value This command is used to set or clear the bit at the offset in the string value stored at the key
8 SETEX key seconds value This command is used to set the value with the expiry of a key
9 SETNX key value This command is used to set the value of a key, only if the key does not exist
10 SETRANGE key offset value This command is used to overwrite the part of a string at the key starting at the specified offset
11 STRLEN key This command is used to retrieve the length of the value stored in a key
12 MSET key value [key value …] This command is used to set multiple keys to multiple values
13 MSETNX key value [key value …] This command is used to set multiple keys to multiple values, only if none of the keys exist
14 PSETEX key milliseconds value This command is used to set the value and expiration in milliseconds of a key
15 INCR key This command is used to increment the integer value of a key by one
16 INCRBY key increment This command is used to increment the integer value of a key by the given amount
17 INCRBYFLOAT key increment This command is used to increment the float value of a key by the given amount
18 DECR key This command is used to decrement the integer value of a key by one
19 DECRBY key decrement This command is used to decrement the integer value of a key by the given number
20 APPEND key value This command is used to append a value to a key

Next TopicRedis Hashes

You may also like