Skip to main content

key-value-ds

File based Key-Value datastore

Supports basic CRD (Create, Read, Delete)

Functionalities:

  1. It can be initialized using an optional file path. If one is not provided, it will reliably create itself using uuid.
  2. Key string capped at 32 characters and Value must be a JSON object capped at 16KB. (These values can be changed in config.py)
  3. Every key supports setting a Time-To-Live property when it is created. This property is optional. If provided, it will be evaluated as an integer defining the number of seconds. Once the Time-To-Live for a key has expired, the key will no longer be available for Read or Delete operations.
  4. Only one process can access the datastore (local file) at a time.
  5. Thread safe.

Usage:

Creating an instance
import key_value_ds
ds_instance = key_value_ds.get_instance()

Note: If file_path is provided in the get_instance() call, it will obtain lock on that file using fcntl. If object is created for the same file path twice, BlockingIOError is thrown.

Creating an data
data_key = 'test_key'
data_value = {"value": 1}  # must be a JSON
time_to_live = 5*1000  # in milliseconds
ds_instance.create(data_key, data_value, ttl=time_to_live)
Retrieving data
retrieve_key = 'test_key'
ds_instance.get(retrieve_key)   # returns {"value": 1} if retrieved within 5 seconds else ValueError
Deleting data
key_to_delete = 'test_key'
ds_instance.delete(key_to_delete)  # key-value is removed from the datastore
Delete all data
ds_instance.delete_all()

Metadata

Release files for key-value-ds 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for key-value-ds 1.0.3
File Size Uploaded
key_value_ds-1.0.3.tar.gz 5.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for key-value-ds 1.0.3
File Interpreter ABI Platform
key_value_ds-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 12.5 kB

Release files / key_value_ds-1.0.3.tar.gz

Download URL key_value_ds-1.0.3.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b5dfd4f5ebbf2c8f0fbde8556ca7d75f2366a08363fb2816b804b8e7cc1e8f3c
BLAKE2b-256 checksum
How to use checksums
f1679e86eb8f5fecfb06e6654256e4e2b0ae2d18fc0ac08e1a32f18cf92490b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2

Release files / key_value_ds-1.0.3-py3-none-any.whl

Download URL key_value_ds-1.0.3-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab2a852dfff0fc269c473360cf255a172e95fc00677cfa0ceec110cf801c454c
BLAKE2b-256 checksum
How to use checksums
483b9bec56506828cce1196692d8f1350e3da842e3c7dc53e204466f94e2c934
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page