miniGoStore is a tiny in-memory caching service written in Go.
It provides a lightweight key–value store with a custom, simple TCP-based protocol.
miniGoStore offers a simple protocol for storing, fetching, and querying TTLs of currently stored data.
- The protocol is line-based (
\nterminated). - Commands and options are case-insensitive.
- Each command returns exactly one response.
- One TCP connection represents one client session.
PASS
Authenticate the client.
GET
Return the value stored at , or (nil) if the key does not exist.
SET [NX|XX] [EX|PX <seconds|milliseconds>] [GET]
Store at
- NX - Set only if the key does not exist.
- XX - Set only if the key already exists.
- EX - Set expiration time in seconds.
- PX - Set expiration time in milliseconds.
- GET - Return the previous value stored at the key.
GETEX [EX|PX <seconds|milliseconds>] [PERSIST]
Return the value of and optionally update its TTL.
- EX/PX Set a new expiration.
- PERSIST Remove any existing expiration.
TTL
Return the remaining time-to-live of .
-1 if the key exists but has no expiration.
-2 if the key does not exist.
PING
Check server liveness. Get back PONG.
DEL
Delete and its associated value.
QUIT
Close the client connection.
A background cleanup routine continuously scans and removes TTL-expired keys and values.
The store package contains unit tests for command behavior.
Alongside the server executable, a benchmark script is provided: ./cmd/benchmark/main.go
It can be used to stress-test concurrency, throughput, and locking behavior.
The server requires authentication using the PASS command.
The provided password is:
- hashed at startup
- never stored in plaintext
- explicitly erased from memory after hashing (best-effort)
go build ./cmd/server/main.go
./main <password> [port]The port is set to 8080 by default if none is provided.
miniGoStore is a learning project inspired by Redis but intentionally simpler:
- No persistence (RDB/AOF)
- No pub/sub
- No transactions
- Minimal command set
Think twice before trying to use it in your app :)
Built by https://github.com/bobbyskywalker 🦫
Fork & post PRs freely if you are interested in this project :)
MIT License. See LICENSE tab.