Skip to main content

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 API with implementations for local JSON and SQLite3 storage backends and a JSON convenience layer.

Quickstart

from nr.caching.stores.sqlite import SqliteStore
from nr.caching.adapters.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.4.1.tar.gz (9.6 kB view hashes)

Uploaded Source

Built Distribution

nr.caching-0.4.1-py3-none-any.whl (10.5 kB view hashes)

Uploaded Python 3

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