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.
pip install justdb
from justdb import JustDB
j = JustDB() # paths will be relative to here, or if a .just file can be found
# 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.
UPDATE: I was comparing against redis docker performance!
It will search for a .just
file to consider as root, upwards.
justdb kill
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).
Proof-of-concept. Please leave some feedback about which direction you'd like to see this go.