Skip to main content

Let you forget you're using a database. Simple and high-performance persistent database solutions. 一个伪装成字典的数据库。 简单且高性能的持久化数据库解决方案。

Project description


FlaxKV

Let you forget you're using a database — Simple and high-performance persistent database solution

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

English | 简体中文


A persistent database masquerading as a dictionary.

The flaxkv module provides a dictionary-like interface for interacting with high-performance key-value databases (LMDB, LevelDB). It abstracts the complexities of direct database interaction, allowing users to perform CRUD operations in a simple and intuitive manner. You can use it just like a Python dictionary without worrying about it blocking your main process at any stage.

Use Cases

  • Key-Value Structure: flaxkv is suitable for storing simple key-value structured datasets.

  • High-Frequency Writing: flaxkv is very suitable for scenarios that require high-frequency insertion/updating of data.

  • Machine Learning: flaxkv is perfect for storing various embeddings, images, texts, and other large datasets with key-value structures in machine learning.


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 dbdict
import numpy as np

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

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

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

assert 'key2' in d

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

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

print(len(d))

You might have noticed that even when the program ends, we didn't use d.close() to release resources! Everything will be handled automatically. More importantly, as a persistent database, it offers performance close to dictionary (in-memory) access! (There should be a benchmark here..)

P.S.: Of course, you can also manually call d.close() to release resources immediately~.

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.2.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

flaxkv-0.1.2-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for flaxkv-0.1.2.tar.gz
Algorithm Hash digest
SHA256 05b16ab4f0424673a6eb9bd39160909cdd7045a02310d3003f861e9c9649d196
MD5 f3209ed7cf66c6c2202299a1f0e09f76
BLAKE2b-256 27404831a9827bcf83b2d32f0b5e0e2bb14a99561e327f0dca63066f0d32ebaf

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for flaxkv-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e2a98c511e9819d18ed5fc9babeb29b8937d7bd01a9ec2c8d34baaf38c0d060b
MD5 5ffa25afddf0735ab827182abac34d8a
BLAKE2b-256 c3d2232aa2e70f12aa4c9a7416f94ace43a7ec7ef61975794962aeb3fd0652da

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