Skip to main content

A file-based value store for bytes and strings.

Project description

Keeper is a filesystem-based, content-addressable value store for Python 3.

Installation

$ pip install keeper

Using Keeper

Keeper is constructed with a Storage object. This example uses FileStorage:

from keeper import FileStorage, Keeper

Pass a directory path to a FileStorage instance, and then pass the Storage instance to the Keeper:

with FileStorage("/some/directory/") as storage:
     with Keeper(storage) as k:
        ...

Add string or bytes objects, and get a key in return:

key = self.keeper.add("The quick brown fox jumped over the lazy dog")

Use the key to retrieve the string:

value = keeper[key].as_string()

Add another string with some metadata:

key = keeper.add(text, mime="text/plain", filename="foo.txt", author="Joe Bloggs")

Retrieve metadata:

print(keeper[key].meta.mime)

Add a binary stream you can write to:

with keeper.add_stream() as stream:
     stream.write(b'A large number of bytes')

After the stream has closed, retrieve the key:

key = stream.key

Write cacheing

On slow filesystems, such as USB flash drives, it’s possible to buffer writes in RAM, using a storage intermediary called WriteCacheStorage. Use it like this:

from keeper import FileStorage, WriteCacheStorage, Keeper

with FileStorage("/some/directory/") as file_storage:
    with WriteCacheStorage(file_storage) as cached_storage:
        with Keeper(cached_storage) as k:
            ...

Closing the WriteCacheStorage instance will block until all pending writes have been committed to the underlying FileStorage.

Deployment

To build and deploy a package to PyPI:

$ bumpversion patch
$ python setup.py sdist bdist_wheel
$ twine upload dist/*

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

keeper-1.1.1.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

keeper-1.1.1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file keeper-1.1.1.tar.gz.

File metadata

  • Download URL: keeper-1.1.1.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.0

File hashes

Hashes for keeper-1.1.1.tar.gz
Algorithm Hash digest
SHA256 f3a72d9ac0b6a6f4ab075ff670c3f77b66fc27f173c2479e7ff21afb10568f9a
MD5 38362a9c13a865ac3a1a89bdbbcd6687
BLAKE2b-256 e233bdf9caa4fdced1d668f7fd91b3d898b275c0549d89e193c4c2be4d8ad8d1

See more details on using hashes here.

File details

Details for the file keeper-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: keeper-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.0

File hashes

Hashes for keeper-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dc7570038615adc0a2b6f25df1c06680a963af57f73fdf0901eaad8dcad97010
MD5 1f66635477e002d3f64b6270046d58b5
BLAKE2b-256 29857e50d0ee83885ce6ee9b7ad2d0c0d6f77a0f4a6e6c962f55568ee251fc9e

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