##Redis Rapid Reference: Mastering All Commands with PowerShell 🚀💡✨🔮
Tags: redis, coding, opensource, codenewbie
Published: 2024-03-07 09:28:28

# 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/](https://docs.docker.com/get-docker/)

## Table of Contents

1. [Introduction to Redis](#introduction-to-redis) 🌟
2. [SET and GET Commands](#set-and-get-commands) 🔧
3. [SETNX Command](#setnx-command) 🛡️
4. [MSET and MGET Commands](#mset-and-mget-commands) 🚀
5. [LPUSH and LPOP Commands](#lpush-and-lpop-commands) 🔄
6. [SADD Command](#sadd-command) ➕
7. [ZADD and ZRANGE Commands](#zadd-and-zrange-commands) 📊
8. [HSET Command](#hset-command) 🏷️
9. [PUBLISH Command](#publish-command) 📢
10. [SUBSCRIBE 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.
  ```plaintext
  127.0.0.1:6379> SET name shubham
  OK
  ```

- **GET**: Get the value of a key.
  ```plaintext
  127.0.0.1:6379> GET name
  "shubham"
  ```

## SETNX Command

- **SETNX**: Set the value of a key, only if the key does not exist.
  ```plaintext
  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.
  ```plaintext
  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.
  ```plaintext
  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.
  ```plaintext
  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.
  ```plaintext
  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.
  ```plaintext
  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.
  ```plaintext
  127.0.0.1:6379> PUBLISH notifications hey
  (integer) 1
  ```

## SUBSCRIBE Command

- **SUBSCRIBE**: Subscribe to channels.
  ```plaintext
  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! 🎉