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
set thorin:food lembas
OK
set thorin:weapon Orcrist
OK
json thorin:
{"food":"lembas","weapon":"Orcrist"}
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
json <prefix> return json with matching key prefix trimmed
Configuration
By default, erebor listens on 127.0.0.1:8044. You can change this as follows:
$ erebor -b 0.0.0.0 -p 8055
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.
To run in durable mode, simply specify the -d
option:
$ erebor -d /path/to/database
This will save the database to disk at the specified path.
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
Built Distribution
File details
Details for the file erebor-2.0.6.tar.gz
.
File metadata
- Download URL: erebor-2.0.6.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df3deff91676f794924e8243464ce27eee3061a0edf699d9da2222b5e07180f9 |
|
MD5 | 7cd99e9e7ed74de3a7a479b2a25b68dd |
|
BLAKE2b-256 | 4a22c72c576f2595ef2c1a79f129f73adb421eed3d33b60c98c4104807340c5f |
File details
Details for the file erebor-2.0.6-py3-none-any.whl
.
File metadata
- Download URL: erebor-2.0.6-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7e11cec37fd29718715e9efa55ebf9d84266417089d76f3cab84890a8be6cc9 |
|
MD5 | 0704228076983d12e3a043ab571d42d6 |
|
BLAKE2b-256 | be039e98ffe1ba647a0cfbb11055aa0cc17e35f31fc70c059810f12b1ba8d1b1 |