Initial redis skill implementation

This commit is contained in:
Azat
2026-02-02 23:44:22 +01:00
commit 007c151a1c
3 changed files with 259 additions and 0 deletions

119
SKILL.md Normal file
View File

@@ -0,0 +1,119 @@
---
name: redis
description: Redis in-memory cache with persistence and pub/sub
metadata:
version: "1.0.0"
vibestack:
main: false
metrics-port: 9121
---
# Redis Skill
Installs and configures [Redis](https://redis.io/) in-memory data store for caching, pub/sub messaging, and session storage.
## Features
- In-memory key-value store
- RDB + AOF persistence
- Pub/sub messaging
- Optional authentication
- Memory limit with eviction policy
- Auto-registers with Caddy if domain set
## Configuration
### Environment Variables
| Variable | Default | Description |
|----------|---------|-------------|
| `REDIS_PORT` | `6379` | Redis port |
| `REDIS_PASSWORD` | (none) | Optional authentication password |
| `REDIS_MAXMEMORY` | `100mb` | Memory limit |
| `REDIS_MAXMEMORY_POLICY` | `allkeys-lru` | Eviction policy when memory limit reached |
| `REDIS_DATA_DIR` | `/data/redis` | Persistence directory |
| `REDIS_APPENDONLY` | `yes` | Enable AOF persistence |
| `REDIS_SAVE` | `900 1 300 10 60 10000` | RDB save intervals |
| `REDIS_DOMAIN` | (none) | Domain for Caddy auto-config |
### Output Variables
After starting, the skill exports:
| Variable | Example |
|----------|---------|
| `REDIS_URL` | `redis://:password@localhost:6379` |
## Usage
### As a dependency
```yaml
metadata:
vibestack:
requires:
- redis
```
### Connection
```bash
# Connect with redis-cli
redis-cli -p 6379
# With authentication
redis-cli -p 6379 -a "$REDIS_PASSWORD"
# From application
REDIS_URL=redis://localhost:6379
# or with auth
REDIS_URL=redis://:password@localhost:6379
```
### Common Operations
```bash
# Set a key
redis-cli SET mykey "Hello"
# Get a key
redis-cli GET mykey
# Pub/sub
redis-cli SUBSCRIBE mychannel
redis-cli PUBLISH mychannel "Hello subscribers!"
# Check memory usage
redis-cli INFO memory
```
## Persistence
Redis is configured with both RDB snapshots and AOF (Append Only File):
- **RDB**: Point-in-time snapshots at configured intervals
- **AOF**: Log of all write operations for durability
Data is stored in `REDIS_DATA_DIR` (default: `/data/redis`).
## Memory Management
When `REDIS_MAXMEMORY` is reached, the `REDIS_MAXMEMORY_POLICY` determines behavior:
| Policy | Description |
|--------|-------------|
| `allkeys-lru` | Evict least recently used keys (default) |
| `volatile-lru` | Evict LRU keys with TTL set |
| `allkeys-random` | Evict random keys |
| `noeviction` | Return errors on write |
## Caddy Integration
If the `caddy` skill is present and `REDIS_DOMAIN` is set, Redis will be accessible via HTTPS (useful for Redis Insight or other GUI tools).
## Security
For production use:
1. Always set `REDIS_PASSWORD`
2. Restrict network access
3. Use TLS for external connections