Redis – Strings

  • Post author:
  • Post category:Redis
  • Post comments:0 Comments

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.NoCommand & Description
1SET key valuehttps://adglob.in/blog/redis-string-set-command/
This command sets the value at the specified key.
2GET keyhttps://adglob.in/blog/redis-string-get-command/
Gets the value of a key.
3GETRANGE key start endhttps://adglob.in/blog/redis-string-getrange-command/
Gets a substring of the string stored at a key.
4GETSET key valuehttps://adglob.in/blog/redis-string-getset-command/
Sets the string value of a key and return its old value.
5GETBIT key offsethttps://adglob.in/blog/redis-string-getbit-command/
Returns the bit value at the offset in the string value stored at the key.
6MGET key1 [key2..]https://adglob.in/blog/redis-string-mget-command/
Gets the values of all the given keys
7SETBIT 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
8SETEX key seconds valueadglob.in/blog/redis-string-setex-command/
Sets the value with the expiry of a key
9SETNX key valueadglob.in/blog/redis-string-setnx-command/
Sets the value of a key, only if the key does not exist
10SETRANGE key offset valuehttps://adglob.in/blog/redis-string-setrange-command/
Overwrites the part of a string at the key starting at the specified offset
11STRLEN keyhttps://adglob.in/blog/redis-string-setrange-command-2/
Gets the length of the value stored in a key
12MSET key value [key value …]https://adglob.in/blog/redis-string-mset-command/
Sets multiple keys to multiple values
13MSETNX 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
14PSETEX key milliseconds valuehttps://adglob.in/blog/redis-string-psetex-command/
Sets the value and expiration in milliseconds of a key
15INCR keyhttps://adglob.in/blog/redis-string-incr-command/
Increments the integer value of a key by one
16INCRBY key incrementhttps://adglob.in/blog/redis-string-incrby-command/
Increments the integer value of a key by the given amount
17INCRBYFLOAT key incrementhttps://adglob.in/blog/redis-string-incrbyfloat-command/
Increments the float value of a key by the given amount
18DECR keyhttps://adglob.in/blog/redis-string-decr-command/
Decrements the integer value of a key by one
19DECRBY key decrementhttps://adglob.in/blog/redis-string-decrby-command/
Decrements the integer value of a key by the given number
20APPEND key valuehttps://adglob.in/blog/redis-string-append-command/
Appends a value to a key

Leave a Reply