A simple key-value caching API with default implementations for an SQLite3 storage backend and a JSON convenience layer.
Project description
Note: This package is in the dangerous land of
0.x.y
versions and may be subject to breaking changes with minor version increments.
nr.caching
A simple key-value caching API with default implementations for an SQLite3 storage backend and a JSON convenience layer.
Quickstart
from nr.caching.sqlite import SqliteStore
from nr.caching.json import hash_args, JsonCacheFactory
caching_backend = SqliteStore('.cache.db')
cache_factory = JsonCacheFactory(caching_backend, default_exp=60)
data = cache_factory.namespace('my-namespace').loading(
f'expensive_function_{hash_args(parameters)}',
lambda: expensive_function(*parameters))
Copyright © 2021 Niklas Rosenstein
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
nr.caching-0.3.0.tar.gz
(6.7 kB
view hashes)
Built Distribution
Close
Hashes for nr.caching-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 379dd86047a22afe3c6cad1331763f8557f9dae34702cd980969e3aa557106e9 |
|
MD5 | 49b98ad2954bae93c209dd9c23313ff0 |
|
BLAKE2b-256 | fe61d19fe15f3de7c8e04849ed2e0284629002ac209fa79ecdbe8413c63b8a08 |