justdb
Why
justdb
is a thread/process safe, file-based database, without strain for the developer.
The interesting thing is that there will be a detached process which will receive requests through ZeroMQ. This process will ensure only 1 thread or process can write at a time. Even external processes.
The process will however not write data to files itself, it only communicates permission. Like this, you can make it safe to write/read to a filesystem, and benefit from great speed.
For more capabilities, also read here: just.
Installation
pip install justdb
Using justdb
from justdb import JustDB
j = JustDB()
# write to file (serialization based on filename)
j["bla.json"] = {"a": 1}
# read file (deserialization based on filename)
print(j["bla.json"])
# {"a": 1}
# remove file
j.remove("bla.json")
# also works with other extension **.
j["some/folder/bla.yml"] = {"a": 1}
print(j["some/folder/bla.yml"])
# {"a": 1}
** See supported types.
SPEED
Ok, just
is rather slow. If you want to do fast writing without file extension and file existance checks:
import ujson
def my_read():
with open("some.json") as f:
return ujson.load(f)
result = j.execute(my_read)
Like this, you will be faster than Redis. UPDATE: I was comparing against docker performance!
root path
It will search for a .just
file to consider as root, upwards.
Stop the server
justdb kill
Warning
Note that whatever function you will use with j.execute()
(or with j
in general), you can be assured that it will be the only function running (well, using JustDB
, if you write without justdb to the same files, good luck).
Status
Proof-of-concept. Please leave some feedback about which direction you'd like to see this go.