This project is a simple Redis-like in-memory key-value store implemented in Go. It supports basic operations such as GET, PUT, and DELETE, and uses sharding for concurrency. The server exposes a RESTful API and logs all events and errors to a file.
- In-memory key-value storage
- Sharding for concurrent access
- RESTful API using Gorilla Mux
- File-based event and error logging
- Simple custom hash function for sharding
- URL:
/v1/{key} - Method:
PUT - Body: Raw value (string)
- Response:
key added successfully{key:<key>} - Error: 409 Conflict if key already exists
- URL:
/v1/{key} - Method:
GET - Response: Value as plain text
- Error: 409 Conflict if key does not exist
- URL:
/v1/delete/{key} - Method:
GET - Response:
sucessfully deleted key :<key> - Error: 409 Conflict if key does not exist
- All events and errors are logged to
tmp.login the project directory.
- Install dependencies:
go mod tidy
- Run the server:
go run cmd/main.go
- The server will start on
http://localhost:8080
- Add a key:
curl -X PUT http://localhost:8080/v1/mykey -d 'myvalue' - Get a key:
curl http://localhost:8080/v1/mykey
- Delete a key:
curl http://localhost:8080/v1/delete/mykey
cmd/main.go: Main application codego.mod,go.sum: Go module filestmp.log: Log file (created at runtime)
This project is for educational purposes.