Go to file
Kevin ef5b618a91 Do not flush on exit if there is no file specified 2020-07-24 14:53:18 -05:00
deadsimplekv Do not flush on exit if there is no file specified 2020-07-24 14:41:59 -05:00
docs added flush at exit 2019-06-10 19:01:08 -05:00
tests added get_raw_json and fixed formatting, switched to setuptools 2020-03-28 00:03:16 -05:00
.gitignore added documentation, docs and gitignore 2019-03-01 10:40:49 -06:00
.travis.yml added readme and change py version in travis 2019-03-01 00:16:52 -06:00
CHANGELOG.md Do not flush on exit if there is no file specified 2020-07-24 14:41:59 -05:00
LICENSE implemented most logic and tests 2019-02-28 23:50:06 -06:00
Makefile make sure docs is in main docs folder for gh pages 2019-03-01 10:54:43 -06:00
README.md 6 pub methods 2020-03-28 00:05:37 -05:00
run_tests.sh create directory path of file path if it doesn't exist 2019-09-08 03:47:59 -05:00
setup.py Do not flush on exit if there is no file specified 2020-07-24 14:53:18 -05:00

README.md

DeadSimpleKV

Build Status

As the name implies, this is merely a simple key-value store for Python.

Not counting comments and tests, it is less than 100 lines of code.

It doesn't do anything crazy. It just takes json serializable data and stores it to disk.

You can control when and where to read/write, and that's it.

No bloat, only 6 public methods.

Usage

Install:

python3 setup.py install

Create the KV instance:

# If the file already exists, it will load the json data from it
kv = deadsimplekv.DeadSimpleKV('/path/to/file')

You can specify how often to refresh and flush to file by passing flush_seconds and refresh_seconds respectively.

Get and set values:

# Automatically reads/writes to disk every time unless no file was specified.
# Set flush_seconds or refresh_seconds to None to disable automatic read/write.
# Set them to >0 values to automatically read/write if time has elapsed. 
kv.put('my_key', True)
kv.get('my_key') # returns True.

Delete a key/value pair:

kv.delete('my_key')

Warning: Be sure to keep flush_on_exit set to true or manually flush when destroying the kv instance (such as by exiting your program) to avoid losing data.

Warning: flush_on_exit should be set to false when using the same file from multiple threads or processes, otherwise you will lose data.