# Redis

Redis is used as a fast in‑memory key‑value store for caching and persistence.  
Two instances are provided to separate volatile and durable data usage.

## Instances

- **cache** — ephemeral, non‑persistent store (port `6379`, socket `/run/redis/redis-cache.sock`)  
  Used for transient application caching, sessions, and short‑lived data.
- **persist** — durable store with on‑disk persistence (port `6380`, socket `/run/redis/redis-persist.sock`)  
  Intended for queues, background jobs, or data that must survive restarts.

## Configuration

Host variables:

```yaml
redis:
  enable: true    # required to deploy Redis
  type: redis     # optional; valid values: redis | valkey
```

### Defaults

- `redis.enable`: *not set* (role disabled)
- `redis.type`: `redis`

When `redis.enable` is omitted, no Redis packages or instances are configured.

### Sockets and Ports

| Instance | Socket Path                     | Port  | Persistence |
|-----------|----------------------------------|-------|--------------|
| cache     | `/run/redis/redis-cache.sock`   | 6379  | none         |
| persist   | `/run/redis/redis-persist.sock` | 6380  | yes (RDB)    |

## User Access

- Applications can connect via UNIX sockets (preferred for local access) or TCP (`localhost` on respective ports).

Example:  
```bash
redis-cli -s /run/redis/redis-cache.sock
```
