A minimal in-memory TCP key-value database written in Go.
- Sharded In-Memory Storage: Uses 64 internal shards (
sync.RWMutex) to minimize lock contention across concurrent requests. - Binary Wire Protocol: Lightweight binary protocol over TCP (
localhost:2045). - Basic Operations: Supports
Set(0),Get(1), andDelete(2).
Requests start with a 9-byte header followed by key and value payloads:
+----------------+-------------------+---------------------+
| Type (1 byte) | Key Size (4 byte) | Value Size (4 byte) |
+----------------+-------------------+---------------------+
| Key bytes (length = Key Size) |
+----------------------------------------------------------+
| Value bytes (length = Value Size) |
+----------------------------------------------------------+
- Operations:
0= SET,1= GET,2= DELETE - Endianness: Big-endian for length integers.
Build binaries:
go build -o bin/server ./cmd/server
go build -o bin/client ./cmd/clientStart the server:
./bin/serverRun the client:
./bin/clientRun tests:
go test ./...