# mini-redis A small asynchronous TCP key-value server implementing a focused subset of the Redis RESP protocol. It is an in-memory learning project; it does not need a Redis installation or any external server/client binary. ## Requirements and tasks Install [mise](https://mise.jdx.dev/) and use the pinned Rust toolchain: ```sh mise install mise run install # fetch the exact locked crate versions mise run check # formatting, tests, and Clippy (all + pedantic) mise run run # serve on 127.0.0.1:6379 ``` Cargo commands use `--locked`; crate versions are exact in `Cargo.toml` and `Cargo.lock` is committed. You can also run `cargo run --locked -- --help` for the command-line options. ## Configuration The default bind address is `127.0.0.1:6379`. Set it with either the `MINI_REDIS_BIND` environment variable or `--bind` / `-b`: ```sh MINI_REDIS_BIND=0.0.0.0:6380 mise run run # or cargo run --locked -- --bind 127.0.0.1:6380 ``` The command-line option takes precedence over the environment variable. The server handles Ctrl-C. Binding to a non-loopback interface exposes the server to that network; this MVP has no authentication or encryption. ## Supported commands Commands are sent as RESP arrays of bulk strings. Command names are case-insensitive; keys and values are binary-safe. | Command | Behavior | | --- | --- | | `PING` | Returns `+PONG` | | `PING message` | Returns the message as a bulk string | | `GET key` | Returns the value, or a null bulk string if absent | | `SET key value` | Stores/replaces a value and returns `+OK` | | `DEL key` | Removes one key and returns integer `1` or `0` | Malformed RESP closes the client connection after a protocol error. Unknown commands and invalid command arity return RESP errors. Each bulk argument is limited to 1 MiB and each command to 16 arguments. ## Connection example Send RESP directly over TCP (the bytes below are `PING`): ```sh printf '*1\r\n$4\r\nPING\r\n' | nc 127.0.0.1 6379 ``` Expected response: ```text +PONG ``` For example, an encoded `SET demo hello` request is `*3\r\n$3\r\nSET\r\n$4\r\ndemo\r\n$5\r\nhello\r\n` and responds with `+OK\r\n`. `nc` is only an optional way to manually inspect the TCP protocol; the implementation and tests do not depend on it. ## Limitations Data is held only in process memory and is lost at shutdown. There is no persistence, authentication, TLS, expiry, transactions, or multi-key `DEL`.