Skip to content

A simple key-value store built in Python, exposing a RESTful HTTP interface for CRUD operations. The entire implementation relies solely on Python's standard library, with no external dependencies.

Notifications You must be signed in to change notification settings

KentHawkings/kvstore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple key-value store built in Python, exposing a RESTful HTTP interface for CRUD operations. The entire implementation relies solely on Python's standard library, with no external dependencies.

Getting Started

Prerequisites

  • Python 3.7+
  • Docker

Running the Server Locally with Docker

  1. Build the Docker image:

    make docker-build
  2. Run the Docker container:

    make docker-run

    The server will be accessible at http://localhost:8000.

Testing the Solution

To run the tests, execute the following command from the root of the project:

make test

This command will discover and run all tests in the tests directory.

API Usage

You can interact with the key-value store using any HTTP client, such as curl.

  • Create/Update a key-value pair:

    curl -X POST -H "Content-Type: application/json" -d '{"value": "your_value"}' http://localhost:8000/store/your_key
  • Retrieve a value by key:

    curl http://localhost:8000/your_key
  • Delete a key:

    curl -X DELETE http://localhost:8000/your_key

Missing/Incomplete Features

Persistence

While I've implemented a DB to allow for persistence our our key-value store I wasn't able to finish the implementation in time. As such the app defaults to using the in-memory DB which means data doesn't actually persist between runs. I don't think this would take long to fix at all but it has knock-on effects on the tests and requires updating the makefile to ensure our directory is mounted.

Architecture

Overall the abstraction of the Database, Cache and Store could probably serve to be improved. Additionally there should be some mechanism whereby the story in the webserver can also be configured (using something like Depedency Injection) for greater flexibility and testability.

About

A simple key-value store built in Python, exposing a RESTful HTTP interface for CRUD operations. The entire implementation relies solely on Python's standard library, with no external dependencies.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published