Skip to main content

key-value store

Project description

erebor

Erebor is a lightweight key-value store with a Redis-like syntax.

Installation

To install the erebor server:

pip install erebor

Usage

Run the server like so:

$ erebor

You can verify erebor is running by connecting to 127.0.0.1:8044.

$ nc localhost 8044
keys
[]
set foo bar
OK
keys
['foo']
get foo
bar

API

Erebor recognizes the following commands:

    set   <key> <value>  set a key to a value
    del   <key>          remove a key and its value
    get   <key>          retrieve the value of a key
    keys  [prefix]       return a list of keys starting with prefix

Configuration

Erebor listens on 127.0.0.1:8044. You can change this by modifying the port variable at the top of the file.

$ vim $(which erebor)

You can also change the bind address. However, for security reasons, it is not recommended to bind on 0.0.0.0 and expose the database to the world.

By default, erebor runs in ephemeral mode, where keys are only stored in memory and not persisted to disk. To run in persistence mode, run with the -p option. This will save the database to a local JSON file called keys.db.

Other notes

The erebor API uses vanilla TCP sockets, so you can make API requests using netcat.

$ echo "set home $(cat index.html)" | nc -q 0 localhost 8044
OK

You can also talk to erebor programmatically using any language that can speak TCP:

import socket

# Setup a socket to the host and port where erebor is running.
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("127.0.0.1", 8044))

def erebor(message):
    sock.send(message.encode())
    return sock.recv(1024).decode().strip()

print(erebor("set foo bar"))
# OK
print(erebor("get foo"))
# bar

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

erebor-2.0.3.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

erebor-2.0.3-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file erebor-2.0.3.tar.gz.

File metadata

  • Download URL: erebor-2.0.3.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for erebor-2.0.3.tar.gz
Algorithm Hash digest
SHA256 b83f6c545d03cddd14e7190bcb8170f6c797044d7b73b716cb0d1a40a3c9deb3
MD5 bdd7ebb1bc87784b49780ad59579318a
BLAKE2b-256 442ef531c0d4a5a1efd75201ab8681058d96de7413fc72931639ab4ddced0906

See more details on using hashes here.

File details

Details for the file erebor-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: erebor-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for erebor-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b0ac67440536835da9f29ce6edefcdb6ad8cc74e486bc10b8d1e21583a0d1cc2
MD5 3a42f23526ce4cba62a966d3eaa1b189
BLAKE2b-256 758202156f959f7b33ab43cfe0529fb82e9f229c928ba5cacdf1a92e89085ba8

See more details on using hashes here.

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