Why ?
For the fun o/
Overview
LeakDB is a very simple and fast key value store for Python.
All data is stored in memory and the persistence is defined by the user. A max queue size can be defined for a auto-flush.
API
>>> from leakdb import PersistentQueueStorage
>>> leak = PersistentQueueStorage(filename='/tmp/foobar.db')
# set the value of a key
>>> leak.set('bar', {'foo': 'bar'})
>>> leak.set('foo', 2, key_prefix='bar_')
# increment a key
>>> leak.incr(key='bar_foo', delta=5)
7
>>> leak.incr(key='foobar', initial_value=1000)
1000
# looks up multiple keys
>>> leak.get_multi(keys=['bar', 'foobar'])
{u'foobar': 1000, u'bar': {u'foo': u'bar'}}
# ensure changes are sent to disk
>>> print leak
/tmp/foobar.db 12288 bytes :: 3 items in queue :: 3 items in storage memory
>>> leak.flush(force=True)
/tmp/foobar.db 12338 bytes :: 0 items in queue :: 3 items in storage memory
>>> leak.close()
STORAGE
DefaultStorage :: The default storage, all API operations are implemented set set_multi incr decr get_multi delete
QueueStorage :: Use the DefaultStorage with a queue. You can override the QueueStorage.worker_process method and make what you want when the flush method is called.
from leakdb import QueueStorage
class MyQueueStorage(QueueStorage):
def worker_process(self, item):
""" Default action execute by each worker.
Must return a True statement to remove the item,
otherwise the worker put the item into the queue.
"""
logger.info('process item :: {}'.format(item))
return True
PersistentStorage :: Use the DefaultStorage, otherwise each operation is stored through the shelve module.
PersistentQueueStorage :: Use the QueueStorage and the PersistentStorage.
# see also the API part
from leakdb import PersistentQueueStorage
storage = PersistentQueueStorage(filename="/tmp/foobar.db", maxsize=1, workers=1)
# the queue is auto-flush, each operations check the queue size
storage.set('foo', 1)
TODO
finish the transport layer through zeroMQ
cleanup the code
improves the unittests
write a CLI
benchmark each storage
Metadata
Release files for LeakDB 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| LeakDB-0.2.tar.gz | 5.2 kB | Without provenance | Details |
Release files / LeakDB-0.2.tar.gz
| Download URL | LeakDB-0.2.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8ce8c7aaa0f534afc47d5964bddf200c00ba13fcba0d46cc1140f47b7b54a131
|
|
BLAKE2b-256 checksum How to use checksums |
b17bcf6ccbf87917785e294256b13ee40cb60715ddb272550ccc6032765f272f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for LeakDB 0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.