Skip to main content

A high-performance dictionary database.

Project description


🗲 FlaxKV

A high-performance dictionary database.

PyPI version License Release (latest by date) tests pypi downloads

English | 简体中文


The flaxkv provides an interface very similar to a dictionary for interacting with high-performance key-value databases. More importantly, as a persistent database, it offers performance close to that of native dictionaries (in-memory access). You can use it just like a Python dictionary without having to worry about blocking your user process when operating the database at any time.


Key Features

  • Always Up-to-date, Never Blocking: It was designed from the ground up to ensure that no write operations block the user process, while users can always read the most recently written data.

  • Ease of Use: Interacting with the database feels just like using a Python dictionary! You don't even have to worry about resource release.

  • Buffered Writing: Data is buffered and scheduled for write to the database, reducing the overhead of frequent database writes.

  • High-Performance Database Backend: Uses the high-performance key-value database LMDB as its default backend.

  • Atomic Operations: Ensures that write operations are atomic, safeguarding data integrity.

  • Thread-Safety: Employs only necessary locks to ensure safe concurrent access while balancing performance.

TODO

  • Client-Server Architecture
  • Benchmark

Quick Start

Installation

pip install flaxkv

Usage

from flaxkv import dictdb
import numpy as np

db = dictdb('./test_db')
# or run server `flaxkv run --port 8000`, then:
# db = dictdb('http://localhost:8000', remote=True, db_name='test_db', rebuild=False)

db[1] = 1
db[1.1] = 1 / 3
db['key'] = 'value'
db['a dict'] = {'a': 1, 'b': [1, 2, 3]}
db['a list'] = [1, 2, 3, {'a': 1}]
db[(1, 2, 3)] = [1, 2, 3]
db['numpy array'] = np.random.randn(100, 100)

db.setdefault('key', 'value_2')
assert db['key'] == 'value'

db.update({"key1": "value1", "key2": "value2"})

assert 'key2' in db

db.pop("key1")
assert 'key1' not in db

for key, value in db.items():
    print(key, value)

print(len(db))

Tips

  • flaxkv provides performance close to native dictionary (in-memory) access as a persistent database! (There should be a benchmark here)
  • You may have noticed that in the previous example code, db.close() was not used to release resources! Because all this will be automatically handled by flaxkv. Of course, you can also manually call db.close() to immediately release resources.
  • Since flaxkv saves data by buffered writing, this feature of delayed writing may not write data to the disk in time in some scenarios (such as in Jupyter), in this case, you can use db.write_immediately() to immediately trigger a write operation.

Benchmark

todo

Use Cases

  • Key-Value Structure: Used to save simple key-value structure data.
  • High-Frequency Writing: Very suitable for scenarios that require high-frequency insertion/update of data.
  • Machine Learning: flaxkv is very suitable for saving various large datasets of embeddings, images, texts, and other key-value structures in machine learning.

Citation

If FlaxKV has been helpful to your research, please cite:

@misc{flaxkv,
    title={FlaxKV: An Easy-to-use and High Performance Key-Value Database Solution},
    author={K.Y},
    howpublished = {\url{https://github.com/KenyonY/flaxkv}},
    year={2023}
}

Contributions

Feel free to make contributions to this module by submitting pull requests or raising issues in the repository.

License

FlaxKV is licensed under the Apache-2.0 License.

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

flaxkv-0.1.7.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

flaxkv-0.1.7-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file flaxkv-0.1.7.tar.gz.

File metadata

  • Download URL: flaxkv-0.1.7.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for flaxkv-0.1.7.tar.gz
Algorithm Hash digest
SHA256 a09b0e6a0645a6b7ba68f756aa896a10538b5cb1f6aaeff191567f6497e5554b
MD5 47047a06d0411988e0f148f0a3d16ded
BLAKE2b-256 9d7e72f26039a5170b52ed0ce9e8f77c3792b4cc4faf305e8956a24e22402df3

See more details on using hashes here.

File details

Details for the file flaxkv-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: flaxkv-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for flaxkv-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 bf0d9e8711cdbf3d8604e57d07c36233424306cf67dfc0c16661f3910e5d662b
MD5 a1abf06b524e6a094f72fa7269aaf09c
BLAKE2b-256 39ebaf57b2cb88f660784d6c3bd56b9d048d4c257df01d2fa681aa439044d98e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page