Redis strings commands are used for managing string values in Redis. Following is the syntax for using Redis string commands.
Syntax
redis 127.0.0.1:6379> COMMAND KEY_NAME
Example
redis 127.0.0.1:6379> SET Adglob redis OK redis 127.0.0.1:6379> GET adglob "redis"
In the above example, SET and GET are the commands, while Adglob is the key.
Redis Strings Commands
Following table lists some basic commands to manage strings in Redis.
Sr.No | Command & Description |
---|---|
1 | SET key valuehttps://adglob.in/blog/redis-string-set-command/ This command sets the value at the specified key. |
2 | GET keyhttps://adglob.in/blog/redis-string-get-command/ Gets the value of a key. |
3 | GETRANGE key start endhttps://adglob.in/blog/redis-string-getrange-command/ Gets a substring of the string stored at a key. |
4 | GETSET key valuehttps://adglob.in/blog/redis-string-getset-command/ Sets the string value of a key and return its old value. |
5 | GETBIT key offsethttps://adglob.in/blog/redis-string-getbit-command/ Returns the bit value at the offset in the string value stored at the key. |
6 | MGET key1 [key2..]https://adglob.in/blog/redis-string-mget-command/ Gets the values of all the given keys |
7 | SETBIT key offset valuehttps://adglob.in/blog/redis-string-setbit-command/ Sets or clears the bit at the offset in the string value stored at the key |
8 | SETEX key seconds valueadglob.in/blog/redis-string-setex-command/ Sets the value with the expiry of a key |
9 | SETNX key valueadglob.in/blog/redis-string-setnx-command/ Sets the value of a key, only if the key does not exist |
10 | SETRANGE key offset valuehttps://adglob.in/blog/redis-string-setrange-command/ Overwrites the part of a string at the key starting at the specified offset |
11 | STRLEN keyhttps://adglob.in/blog/redis-string-setrange-command-2/ Gets the length of the value stored in a key |
12 | MSET key value [key value …]https://adglob.in/blog/redis-string-mset-command/ Sets multiple keys to multiple values |
13 | MSETNX key value [key value …]https://adglob.in/blog/redis-string-msetnx-command/ Sets multiple keys to multiple values, only if none of the keys exist |
14 | PSETEX key milliseconds valuehttps://adglob.in/blog/redis-string-psetex-command/ Sets the value and expiration in milliseconds of a key |
15 | INCR keyhttps://adglob.in/blog/redis-string-incr-command/ Increments the integer value of a key by one |
16 | INCRBY key incrementhttps://adglob.in/blog/redis-string-incrby-command/ Increments the integer value of a key by the given amount |
17 | INCRBYFLOAT key incrementhttps://adglob.in/blog/redis-string-incrbyfloat-command/ Increments the float value of a key by the given amount |
18 | DECR keyhttps://adglob.in/blog/redis-string-decr-command/ Decrements the integer value of a key by one |
19 | DECRBY key decrementhttps://adglob.in/blog/redis-string-decrby-command/ Decrements the integer value of a key by the given number |
20 | APPEND key valuehttps://adglob.in/blog/redis-string-append-command/ Appends a value to a key |