Dragonfly is a multi-threaded, memory-efficient reimplementation of the Redis protocol —
same `redis://` wire format, different engine. Slots behind the same `redis` driver with
zero Flow changes.

<Callout title="The one rule">
  Driver id stays `redis`. Dragonfly is an image choice — every KV call through `fx.store` behaves
  identically to Redis or Valkey at the protocol layer.
</Callout>

## Quick start

<Steps>

<Step>
### Pin the image

```typescript title="oke.config.ts"
images: {
  "store.kv": "docker.dragonflydb.io/dragonflydb/dragonfly",
},
```

</Step>

<Step>
### Password + memory

```bash
OKE_STORE_KV_PASSWORD=…
OKE_STORE_KV_MAXMEMORY=256mb   # optional; recipe passes --maxmemory
REDIS_URL=redis://:…@127.0.0.1:6379
```

Command: `dragonfly --requirepass "$OKE_STORE_KV_PASSWORD" --maxmemory "…"`.

Unlike Redis/Valkey, this recipe does **not** pass `--maxmemory-policy` — Dragonfly's
own defaults apply.

</Step>

<Step>
### memlock ulimit

The recipe sets `ulimits.memlock: -1` — required for Dragonfly's shared-nothing design.
If the host forbids unlimited memlock, the container may fail to start.

</Step>

</Steps>

## Required env

| Variable                 | Required?     | Meaning                                             |
| ------------------------ | ------------- | --------------------------------------------------- |
| `OKE_STORE_KV_PASSWORD`  | **Yes**       | `--requirepass`                                     |
| `REDIS_URL`              | **Yes** (app) | `redis://` URL for the driver                       |
| `OKE_STORE_KV_MAXMEMORY` | Optional      | `--maxmemory` (default `0` in the command template) |
| `HEALTHCHECK_PORT`       | Set by recipe | `6379` — used by the image's healthcheck script     |

## Data and backup

The default `store.kv` recipe declares **no named volume** — ephemeral, same as Redis/Valkey.

Keys that must survive go on `{ durable: true }` — a JSONB table on your SQL database.
Dragonfly snapshots are not involved. See [Store · Durable KV](/docs/elements/store#durable-kv).

## Production note

BSL 1.1 — converts to Apache 2.0 on a published change date per release. Free for
self-hosting; the BSL terms restrict offering Dragonfly itself as a commercial managed
service to third parties — running it for your own app is unaffected.

Multi-threaded architecture makes better use of multi-core hosts than single-threaded
Redis under heavy concurrent load. For a managed endpoint with TLS + passkey, see
[Dragonfly Cloud](/docs/providers/dragonfly-cloud).

## What the recipe configures

| Field          | Value                                                 |
| -------------- | ----------------------------------------------------- |
| Container port | `6379`                                                |
| `ulimits`      | `memlock: -1`                                         |
| Healthcheck    | `/usr/local/bin/healthcheck.sh`, every 5s, 10 retries |
| Connection URL | `redis://:pass@host:6379`                             |

## Troubleshooting

<Accordions>
<Accordion title="Container exits — cannot lock memory / memlock">

Host `ulimit -l` is too low. The recipe requests unlimited memlock. Raise the Docker
daemon / systemd limit, or run on a host that allows `memlock: -1`.

</Accordion>
<Accordion title="oke boot: redis driver needs REDIS_URL">

Same driver failure as Redis — export `REDIS_URL` or let `oke dev` write it. Wrong
password yields Redis-protocol `NOAUTH` / `WRONGPASS` from the server.

</Accordion>
</Accordions>

## Learn more

- [Store · KV](/docs/elements/store#kv) — full Redis-protocol image license table
- [Dragonfly Cloud](/docs/providers/dragonfly-cloud) — the managed equivalent
- [Redis](/docs/recipes/redis) · [Valkey](/docs/recipes/valkey) — the other two peers

## Next

<Cards>
  <Card
    title="Dragonfly Cloud"
    description="Managed Dragonfly."
    href="/docs/providers/dragonfly-cloud"
  />
  <Card title="Valkey" description="Permissive-licensed peer." href="/docs/recipes/valkey" />
  <Card title="PgDog" description="Pooling for the SQL side." href="/docs/recipes/pgdog" />
</Cards>
