Revise Redis under 2 minutes

Revise Redis under 2 minutes

Basic Redis commands to get yourself started

Redis (REmote DIctionary Server) is an in-memory, key-value database, commonly referred to as a data structure server. One of the key differences between Redis and other key-value databases is Redis’s ability to store and manipulate high-level data types. These data types are fundamental data structures (lists, maps, sets, and sorted sets) that most developers are familiar with. Redis’s exceptional performance, simplicity, and atomic manipulation of data structures lends itself to solving problems that are difficult or perform poorly when implemented with traditional relational databases.

To start the Redis server

  1. redis-server
  2. redis-cli

Notes

{key :"value"} → value is always a string (key value pair)

Numbers ⇒ "10020"

Objects ⇒ {key : "{ a : '1' }" }

Array ⇒ {key : "[1,2,3,4]" }


Basic Commands

  1. SET → SET
  2. GET → GET
  3. DEL → DEL
  4. EXISTS → EXISTS
  5. KEYS * → displays all available keys
  6. FLUSHALL → Deletes everything
  7. TTL → Time to live { TTL }
  8. EXPIRE → EXPIRE
  9. SETEX → SETEX

ARRAY OPERATIONS

  1. LPUSH → insert from left side → LPUSH
  2. RPUSH → insert from right side → RPUSH
  3. LPOP → Delete from left → LPOP
  4. RPOP →Delete from right → RPOP
  5. LRANGE → Iterating through the array → LRANGE
  6. SADD → Allows only unique String elements in the array ( tip : if you have to insert words with space write it within double quotes else it will take it as 2 words ; by default it takes input as Strings

    { SADD

  7. SMEMBERS → SMEMBERS


HASHES (kind of objects)

  1. HSET → HSET
  2. HGET → HGET
  3. HGETALL → HGET
  4. HDEL → HDEL
  5. HEXISTS → HEXISTS → returns 0 or 1

Did you find this article valuable?

Support Rohit Jaiswal's Blog by becoming a sponsor. Any amount is appreciated!