Store objects in caches at startup time.
Project description
Escondite
Escondite is a simple caching library for Python that allows you to store and retrieve data with string keys. Escondite is used by the Bolinette project to cache classes at script load time.
Installation
$ pip install escondite # or use your preferred package manager
Usage
Escondite provides a Cache class that can be used as a singleton or instantiated as needed.
You can also use the default user cache instance __user_cache__ to store everything in a single global cache.
from collections.abc import Callable
from escondite import Cache, __user_cache__
def cache_class[**P, T](cls: Callable[P, T], *, cache: Cache | None = None) -> Callable[P, T]:
Cache.with_fallback(cache).add('stored_classes', cls)
return cls
@cache_class
class MyClass:
pass
assert 'stored_classes' in __user_cache__
assert __user_cache__.get('stored_classes') == {MyClass}
In this example, the cache_class decorator adds the decorated class to the cache under the key 'stored_classes'.
If the cache funtion is called without a specific cache, it uses the global __user_cache__ instance with the with_fallback method.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file escondite-0.1.2.tar.gz.
File metadata
- Download URL: escondite-0.1.2.tar.gz
- Upload date:
- Size: 2.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a567e096b7c25343bb7890b41521668fdbe3fdd76509d9ce2047c1f87d05056d
|
|
| MD5 |
526900fd7506b28ff3f20eb8ca8d77d7
|
|
| BLAKE2b-256 |
a9f3907a17de810dd3047e93fd699675422e9d00d2db266b2a409301f1a05f53
|
File details
Details for the file escondite-0.1.2-py3-none-any.whl.
File metadata
- Download URL: escondite-0.1.2-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db0427fd0628874c800b4164333d342a65ad52a0ea006e2387f84755f2fcf0a7
|
|
| MD5 |
5959e7dfa68600f36eda8b1bf455f5bd
|
|
| BLAKE2b-256 |
34f1abeee0105c33d8f3ad1792baae8d8016211c1dceb317a7723f37c734c37c
|