> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ahmadraza.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Redis

### **Redis Quick Setup Guide**

#### **1. Installing Redis**

**For Ubuntu/Debian:**

```bash theme={null}
sudo apt update && sudo apt install redis redis-tools
```

**Verify Installation:**

```bash theme={null}
redis-cli -h <redis_host> -p <redis_port> PING
```

#### **2. Managing Redis Service**

```bash theme={null}
sudo systemctl start redis    # Start Redis
sudo systemctl enable redis   # Enable Redis on boot
sudo systemctl status redis   # Check Redis status
```

#### **3. Configuring Redis**

Edit Redis configuration file:

```bash theme={null}
sudo nano /etc/redis/redis.conf
```

* Set a password: `requirepass yourpassword`
* Change the bind address if needed.

Restart Redis after changes:

```bash theme={null}
sudo systemctl restart redis
```

#### **4. Flushing Redis Database**

```bash theme={null}
redis-cli FLUSHALL    # Flush all databases
redis-cli FLUSHDB     # Flush the current database
```

#### **5. Basic Redis Commands**

```bash theme={null}
redis-cli SET key "value"   # Set a key-value pair
redis-cli GET key           # Retrieve value of a key
redis-cli DEL key           # Delete a key
redis-cli KEYS *            # List all keys
redis-cli EXISTS key        # Check if a key exists
redis-cli TTL key           # Check time-to-live for a key
redis-cli INCR counter      # Increment a key's value
redis-cli DECR counter      # Decrement a key's value
```

#### **6. Installing RedisInsight (Redis GUI)**

Download and install RedisInsight:

```bash theme={null}
wget https://downloads.redisinsight.redis.com/latest/redisinsight-linux64.tar.gz
mkdir redisinsight && tar -xvzf redisinsight-linux64.tar.gz -C redisinsight
cd redisinsight && ./redisinsight
```

Access RedisInsight via browser at `http://localhost:8001` and connect to your Redis instance.

### **Conclusion**

Redis is now set up and ready to use. You can manage it via CLI or RedisInsight for a GUI-based experience.
