##Redis Rapid Reference: Mastering All Commands with PowerShell ๐๐กโจ๐ฎ
Shubham Srivastava
Posted on March 7, 2024
Redis Documentation
Welcome to the Redis documentation! Redis is an open-source, in-memory data structure store used as a database, cache, and message broker. It supports various data structures such as:
- Strings
- Hashes
- Lists
- Sets
- Sorted sets
- Bitmaps
- Hyperloglogs
- Geospatial indexes with radius queries
In this documentation, we'll cover basic commands and functionalities of Redis using the provided PowerShell commands. ๐๐ก
Getting Started
First, make sure you have Docker installed on your system to run Redis in a containerized environment.
Install Docker
Follow the instructions on the official Docker website to install Docker on your system: https://docs.docker.com/get-docker/
Table of Contents
- Introduction to Redis ๐
- SET and GET Commands ๐ง
- SETNX Command ๐ก๏ธ
- MSET and MGET Commands ๐
- LPUSH and LPOP Commands ๐
- SADD Command โ
- ZADD and ZRANGE Commands ๐
- HSET Command ๐ท๏ธ
- PUBLISH Command ๐ข
- SUBSCRIBE Command ๐ก
Introduction to Redis
Redis is a powerful, open-source, in-memory data structure store known for its performance and versatility. It supports various data structures like strings, hashes, lists, sets, and more, making it ideal for caching, real-time analytics, messaging queues, and much more.
SET and GET Commands
- SET: Set a key to hold a string value.
127.0.0.1:6379> SET name shubham
OK
- GET: Get the value of a key.
127.0.0.1:6379> GET name
"shubham"
SETNX Command
- SETNX: Set the value of a key, only if the key does not exist.
127.0.0.1:6379> SETNX user:4 Ayush NX
OK
MSET and MGET Commands
- MSET: Set multiple keys to multiple values in a single atomic operation.
- MGET: Retrieve the values of multiple keys.
127.0.0.1:6379> MSET id:1 "hey" id:2 "hello"
OK
127.0.0.1:6379> MGET id:1 id:2
1) "hey"
2) "hello"
LPUSH and LPOP Commands
- LPUSH: Add one or more values to the beginning of a list.
- LPOP: Remove and return the first element of a list.
127.0.0.1:6379> LPUSH messages hey
(integer) 1
127.0.0.1:6379> LPOP messages
"hey"
SADD Command
- SADD: Add one or more members to a set.
127.0.0.1:6379> SADD ip 1
(integer) 1
ZADD and ZRANGE Commands
- ZADD: Add one or more members to a sorted set.
- ZRANGE: Return a range of members in a sorted set.
127.0.0.1:6379> ZADD no 1 shubham
(integer) 1
127.0.0.1:6379> ZRANGE no 0 -1
1) "shubham"
HSET Command
- HSET: Set fields in a hash stored at a specified key.
127.0.0.1:6379> HSET bike:1 model Deimos brand Ergonom type 'Enduro bikes' price 4972
(integer) 4
PUBLISH Command
- PUBLISH: Publish a message to channels.
127.0.0.1:6379> PUBLISH notifications hey
(integer) 1
SUBSCRIBE Command
- SUBSCRIBE: Subscribe to channels.
127.0.0.1:6379> SUBSCRIBE notifications
1) "subscribe"
2) "notifications"
3) (integer) 1
Congratulations! You have successfully learned some basic Redis commands and functionalities. Redis offers a wide range of features for managing and manipulating data efficiently. Explore further to unlock the full potential of Redis in your applications.
๐ Happy coding with Redis! ๐
Posted on March 7, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.