Skip to main content

layered-persistence

PyPI version License

Flexible, multi-layer key-value persistence library for Python and MicroPython. In-memory, file, and HTTP storage, with simple pluggable API.


Features

  • Persistent key-value storage with multiple, cascading "layers"
  • Storage backends: RAM, JSON file, remote HTTP
  • Supports async and sync use
  • Lightweight, only core Python dependencies
  • Optional HTTP server for networked persistence

Installation

pip install layered-persistence

or

python -m pip install layered-persistence

or

python3 -m pip install layered-persistence

Quickstart

from layered_persistence import LayeredPersistence, RuntimeLayer, FileLayer

# Use both in-memory (fast) and file (persistent) layers
store = LayeredPersistence(layers=[
    RuntimeLayer(),
    FileLayer(directory="./data")
])

# Store and retrieve a value
await store.set('foo', {'bar': 123})
val = await store.get('foo')
await store.set('foo', {'bar': val["value"]["bar"]+1})
print(val)  # {'value': {'bar': 123}}

Layers

  • RuntimeLayer — Fastest, memory only, cleared on reboot.
  • FileLayer — Stores each key as ./directory/key.json.
  • HttpLayer — For network/remote server persistence (see docs).

Layers can be stacked; reads backfill for speed, writes cascade for durability.


HTTP Server

Expose your store as a simple HTTP API:

from layered_persistence import serve_via_http, LayeredPersistence, RuntimeLayer

store = LayeredPersistence([RuntimeLayer()])
serve_via_http(store, port=8080)

License

MIT

Release files for layered-persistence 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for layered-persistence 0.0.3
File Size Uploaded
layered_persistence-0.0.3.tar.gz 7.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for layered-persistence 0.0.3
File Interpreter ABI Platform
layered_persistence-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 15.7 kB

Release files / layered_persistence-0.0.3.tar.gz

Download URL layered_persistence-0.0.3.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1661b09e37af0f921c83cb7f6f391cf1d9b0f85355db67fe1ff4c84cbf70376e
BLAKE2b-256 checksum
How to use checksums
1dc519ca9b702bb37e610afc82d1573d8566e893896841c71a58bc957cdfc377
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / layered_persistence-0.0.3-py3-none-any.whl

Download URL layered_persistence-0.0.3-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f338ced657d5f88c113b8072150371425009437dbb595f097a9d30b14d114e4d
BLAKE2b-256 checksum
How to use checksums
948fca1a08b9a781670bf9edd9cc051139d35d63f7f0a9cec5df2dc31a9a54ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page