Skip to main content

Simple Miniature key-value datastore

Project description

kvault

License Tests Lint Docker Version Codacy Badge

kvault is a simple Miniature Key-Value Datastore in Python with a Redis-like interface.

Requirements

  1. Python 3.10+

    Python is the programming language of choice for this project, therefore, will be required to be available in the system. One can download and setup Python in their local development environment following the steps provided in the link.

  2. Poetry

    Poetry is the dependency manager & packaging tool used for this project and can be installed following the setup provided in the link as well.

  3. virtualenv

    Used to create virtual environments for installing & setting up Python dependencies.

Setup

Running locally, will require a virtualenv setup and that can be done by following the instructions:

virtualenv .venv

This will create a virtual environment in the current root directory of the project.

Next, install the required dependencies:

poetry install

This installs the dependencies for the project.

Running

by default, the kvault server runs on localhost:31337.

The following options are supported:

Usage: kvault.py [options]

Options:
  -h, --help            show this help message and exit
  -d, --debug           Log debug messages.
  -e, --errors          Log error messages only.
  -t, --use-threads     Use threads instead of gevent.
  -H HOST, --host=HOST  Host to listen on.
  -m MAX_CLIENTS, --max-clients=MAX_CLIENTS
                        Maximum number of clients.
  -p PORT, --port=PORT  Port to listen on.
  -l LOG_FILE, --log-file=LOG_FILE
                        Log file.
  -x EXTENSIONS, --extension=EXTENSIONS
                        Import path for Python extension module(s).

Note that the above output can be obtained from the below command:

python cli.py -h

To run with debug logging on port 31339, for example:

python kvault.py -d -p 31339

This will result in an output like below:

  .--.
 /( @ >    ,-.  KVault 127.0.0.1:31339
/ ' .'--._/  /
:   ,    , .'
'. (___.'_/
 ((-((-''

This indicates that the server is running and awaiting client connections

Client setup should be simple, in another terminal, open a new Python console to interact with the kvault server:

from client import Client

client = Client()
client.set('key', {'name': 'Charlie', 'pets': ['mickey', 'huey']})

print(client.get('key'))  # {'name': 'Charlie', 'pets': ['mickey', 'huey']}

A sample of the expected interaction of a client and kvault server

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kvault-0.1.0.tar.gz (20.0 kB view hashes)

Uploaded Source

Built Distribution

kvault-0.1.0-py3-none-any.whl (22.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page