redis · v1.0 · 2026-07-20 · sha256 c7c5d4fdacb489f4
redis v1.0A
Immutable. This exact content never changes and is served at /api/v1/blob/c7c5d4fdacb489f4.
---
name: redis
description: In-memory data store.
license: MIT
metadata:
author: vant
version: "1.0"
---
# Redis
> In-memory data store.
---
## When To Use
- Caching
- Sessions
- Real-time
- Rate limiting
---
## What To Do
### 1. Connect
```javascript
import { createClient } from 'redis'
const client = createClient({
url: 'redis://localhost:6379'
})
await client.connect()
```
### 2. Operations
| Command | What |
|---------|------|
| get/set | String values |
| hget/hset | Hash values |
| lpush/lrange | Lists |
| sadd/smembers | Sets |
| publish | Pub/sub |
### 3. Patterns
```javascript
// Cache
await client.set('user:1', JSON.stringify(user))
const user = JSON.parse(await client.get('user:1'))
// Session
await client.setex(`sess:${id}`, 3600, data)
// Rate limit
const count = await client.incr(`ratelimit:${key}`)
```
### 4. Use Cases
| Use | Benefit |
|-----|----------|
| Cache DB | Speed |
| Session store | Speed |
| Pub/Sub | Real-time |
| Rate limit | Security |
---
## Output
```
## Redis
| Key | Type | TTL |
|-----|------|-----|
| user:1 | string | [n]s |
### operations
- [n] total
```
---
**Role**: Redis Operator
**Input**: Keys, values
**Output**: Fast data
> In-memory speed.