Design a site like this with WordPress.com
Get started

Redis Overview

Redis is a project by Redis Labs whose sole purpose is to implement an in-memory database that supports various data structures. Originally developed by Salvatore Sanfilippo in 2009, its current version is 6.0.9 as of September 11, 2020.

Redis is open-source and is under BSD license. Mainly its of key-value nature and written in ANSI C.

Useful Redis Commands

  1. Setting a value:
    SET chapter 67
  2. Retrieving a value:
    GET chapter
    “67”
  3. Setting multiple key-values:
    MSET start “Fatiha” complete “Naas”
    OK
  4. Incrementing a value:
    INCR chapter
    (integer) 68
  5. Decrementing a value:
    DECR chapter
    (integer) 67
  6. If a value exists:
    EXISTS chapter
    (integer) 1
  7. When a value exists not:
    EXISTS name
    (integer) 0
  8. Removing a value:
    DEL chapter
    (integer) 1
  9. Removing all keys:
    FLUSHALL
    OK
  10. Setting a server name:
    SET server:name Zend
    OK
  11. Getting a server name:
    GET server:name
    “Zend”
  12. Setting a server port:
    SET server:port 8083
    OK
  13. Getting a server port:
    GET server:port
    “8083”
  14. Renaming a key:
    RENAME chapter sura
    OK
  15. Authenticating a user:
    AUTH MyUserName PasswordIs123
    OK
  16. Assigning a name to current connection:
    CLIENT SETNAME Farial
  17. Retrieving the current client’s name:
    CLIENT GETNAME
    “Farial”
  18. Printing any value:
    ECHO “Quran.”
    “Quran.”
  19. Closing server connection:
    QUIT
    OK
  20. Setting a hash value:
    HSET myhash f1 5
    1
  21. Getting the hash value:
    HGET myhash f1
    “5”
  22. Getting number of hash fields:
    HLEN myhash
    1
  23. Adding key-value to a list:
    LPUSH ThisList 1 2 3
    (integer) 3
  24. Sorting a list:
    SORT ThisList
    1 2 3
    (Sorts in ascending order, to reverse the sorting – add DESC to the command)
  25. Removing the last value from list:
    LPOP ThisList
    “3”
  26. Adding members to aset:
    SADD Set 3 2 1
    (integer) 3
  27. Checking members of a set:
    SMEMBERS Set
    (1)”3″
    (2)”2″
    (1)”1″
  28. Joining two sets:
    SUNION Set1 Set2
  29. Difference between two sets:
    SDIFF Set1 Set2

There are more commands available to work with a Redis database if you need. You may find them on http://www.redis.io .

Advertisement

Published by Farial Mahmod Tishan

Life-long learner. Developing Flutter apps on Parrot Linux OS .

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: