All writing

flashkv

FlashKV is a lightweight, Redis-inspired key-value server written in Go. It provides a simple TCP text protocol, an interactive client mode, and append-only-file (AOF) persistence.

Project Summary

FlashKV is designed as a minimal, high-performance learning/experimentation project for in-memory key-value storage with concurrency and durability basics: - In-memory map with thread-safe access (sync.RWMutex) - TCP server with concurrent connection handling - Basic commands: SET, GET, DEL - AOF persistence with periodic async flush and startup replay - Benchmark script for concurrent pipelined load testing


Features


Architecture

Top-level structure


Requirements

Note: If your local Go version differs, use a compatible version for your environment.


Installation / Build

Clone and build:

git clone https://github.com/HimanshuSardana/flashkv.git
cd flashkv
go build .

This produces the flashkv binary.

Using Makefile

make build

build-release (optional optimized build + UPX pack):

make build-release

Known issue: make run currently uses go run main.go, which does not include all package files and fails. Use go run . -server or go run . -client instead.


Quick Start

1) Start server

go run . -server

By default, server listens on 127.0.0.1:6379.

2) Start client (new terminal)

go run . -client

You should see an interactive prompt.

3) Try commands

> SET name flashkv
OK
> GET name
flashkv
> DEL name
OK
> GET name
ERR not found
> QUIT
Goodbye!

Command Reference

SET key value

Set a string value for a key.

GET key

Get value for a key.

DEL key

Delete a key.


Protocol Notes

Because parsing uses whitespace splitting: - Values cannot include spaces directly. - There is no quoting/escaping support. - Protocol is not Redis RESP.


Persistence (AOF)

FlashKV persists write operations (SET, DEL) to an append-only file:

Operational note: - Running from different working directories creates/uses different appendonly.aof files.


Benchmarking

A benchmark script is provided:

python3 benchmarks/benchmark.py

Default benchmark configuration (in script): - Host: 127.0.0.1 - Port: 6379 - Iterations/client: 10000 for SET + 10000 for GET - Concurrent clients: 10 - Pipeline size: 100

Start the server first, then run the benchmark.


Configuration

Current configuration is code-level constants (no env vars yet):

Environment variables

No environment-variable configuration is implemented at this time.


Development Workflow

Run locally

go run . -server
go run . -client

Build

go build .

Tests

Currently, no Go test files are present in the repository.

go test ./...

(Will report no tests unless tests are added.)

Lint/format

No lint configuration is currently committed.

go fmt ./...

Known Limitations


Roadmap (TODO)

TODO: Confirm and publish maintainers’ prioritized roadmap.

Potential next steps inferred from current design: - [ ] Configurable host/port/AOF path via flags or env vars - [ ] RESP protocol compatibility - [ ] TTL / expiration - [ ] Better shutdown handling and signal support - [ ] AOF compaction / rewrite - [ ] Automated tests and CI - [ ] Linting/static analysis integration - [ ] Docker/devcontainer support


Contributing

TODO: Add contribution guidelines (CONTRIBUTING.md), coding style, and PR process.

For now: 1. Fork the repo 2. Create a feature branch 3. Make focused changes with clear commit messages 4. Open a pull request


License

TODO: Add LICENSE file and update this section with the chosen license.