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

# Configure the Cache-Pot server: ports, auth, persistence

> Configure Cache-Pot's listen address, authentication password, snapshot interval, AOF settings, and expiry sweep using flags or environment variables.

Cache-Pot is configured entirely through CLI flags or environment variables — there is no separate config file. Every flag has an equivalent `CACHEPOT_*` environment variable, making it just as easy to configure whether you are running the binary directly, in a container, or through a process manager.

## Full startup example

The command below starts Cache-Pot with every persistence and security option explicitly set. In practice you only need to include the flags you want to change from their defaults.

```bash theme={null}
cache-pot \
  --addr :6379 \
  --auth mysecretpassword \
  --snapshot-path /data/cache-pot.snapshot \
  --snapshot-interval 60s \
  --aof-path /data/cache-pot.aof \
  --aof-fsync everysec \
  --dashboard-addr :8080
```

## Configuration reference

<ParamField name="--addr" type="string" default=":6379">
  TCP address for the RESP2 server. Set to `host:port`. Use `0.0.0.0:6379` to listen on all interfaces.
</ParamField>

<ParamField name="--auth" type="string" default="">
  Password for `AUTH` command authentication. Leave empty to disable authentication. When set, clients must run `AUTH <password>` before issuing any other command.
</ParamField>

<ParamField name="--snapshot-path" type="string" default="cache-pot.snapshot">
  File path for periodic snapshots. Set to an empty string to disable snapshots entirely.
</ParamField>

<ParamField name="--snapshot-interval" type="duration" default="60s">
  How often to write a snapshot to disk. Accepts Go duration strings: `30s`, `5m`, `1h`. You may also supply a bare integer, which is interpreted as seconds.
</ParamField>

<ParamField name="--aof-path" type="string" default="">
  File path for the append-only log. Leave empty (the default) to disable AOF. When set, every write command is appended to this file. On graceful shutdown Cache-Pot compacts the AOF automatically so restarts replay the minimal log.
</ParamField>

<ParamField name="--aof-fsync" type="string" default="everysec">
  AOF fsync policy. Options:

  * `always` — safest, slowest; fsync after every write.
  * `everysec` — default; at most one second of data loss.
  * `no` — fastest; the OS decides when to flush.
</ParamField>

<ParamField name="--sweep-interval" type="duration" default="10s">
  How often the background expiry sweeper runs to purge expired keys.
</ParamField>

<ParamField name="--dashboard-addr" type="string" default=":8080">
  Listen address for the embedded web dashboard. Set to an empty string to disable the dashboard entirely.
</ParamField>

<ParamField name="--version" type="flag">
  Print the server version and exit immediately. No server is started.
</ParamField>

## Using environment variables

Every flag has a `CACHEPOT_` environment variable equivalent. Set the variable before starting the process and the server picks it up automatically.

| Flag                  | Environment Variable         |
| --------------------- | ---------------------------- |
| `--addr`              | `CACHEPOT_ADDR`              |
| `--auth`              | `CACHEPOT_AUTH`              |
| `--snapshot-path`     | `CACHEPOT_SNAPSHOT_PATH`     |
| `--snapshot-interval` | `CACHEPOT_SNAPSHOT_INTERVAL` |
| `--aof-path`          | `CACHEPOT_AOF_PATH`          |
| `--aof-fsync`         | `CACHEPOT_AOF_FSYNC`         |
| `--sweep-interval`    | `CACHEPOT_SWEEP_INTERVAL`    |
| `--dashboard-addr`    | `CACHEPOT_DASHBOARD_ADDR`    |

Environment variables accept the same values as their flag equivalents. Duration variables accept Go duration strings (`60s`, `5m`, `1h`) or a bare integer number of seconds.

<Note>
  When both a flag and its environment variable are supplied, the **flag takes precedence** over the environment variable.
</Note>

## Authentication

When `--auth` is set, every client must issue the `AUTH` command before Cache-Pot will accept any other command. You can pass the password directly to `redis-cli` with the `-a` flag:

```bash theme={null}
redis-cli -p 6379 -a mysecretpassword ping
```

Or authenticate interactively after connecting:

```bash theme={null}
redis-cli -p 6379
AUTH mysecretpassword
PING   # PONG
```

<Warning>
  Cache-Pot does **not** enable authentication by default. Always set `--auth` in production or any network-accessible deployment to prevent unauthorised access.
</Warning>

## Persistence: snapshots vs. AOF

Cache-Pot supports two complementary persistence mechanisms that you can use independently or together.

**Snapshots** write the full dataset to a single file at a regular interval. They are compact and fast to load on restart, but you can lose up to one interval's worth of writes if the process crashes.

**Append-only file (AOF)** records every write command as it happens. If both are enabled and the AOF contains data, Cache-Pot uses the AOF as the authoritative dataset on startup and skips loading the snapshot. This gives you much finer crash-recovery granularity at the cost of a larger file on disk.

<Tip>
  For most single-machine deployments, enabling both gives you the best of both worlds: fast restarts via the snapshot, plus fine-grained recovery via the AOF.
</Tip>
