A simple database-backed cache for storing JSON-serializable values with optional expiration.
Project description
plain.cache
A simple database-backed cache for storing JSON-serializable values with optional expiration.
The Plain Cache stores JSON-serializable values in a CachedItem model.
Cached data can be set to expire after a certain amount of time.
Access to the cache is provided through the Cached class.
from plain.cache import Cached
cached = Cached("my-cache-key")
if cached.exists():
print("Cache hit and not expired!")
print(cached.value)
else:
print("Cache miss!")
cached.set("a JSON-serializable value", expiration=60)
# Delete the item if you need to
cached.delete()
Expired cache items can be cleared by running chores.
CLI
plain cache clear-expired- Clear all expired cache itemsplain cache clear-all- Clear all cache itemsplain cache stats- Show cache statistics
Installation
Install the plain.cache package from PyPI:
uv add plain.cache
Add plain.cache to your INSTALLED_PACKAGES:
# app/settings.py
INSTALLED_PACKAGES = [
# ...
"plain.cache",
]
Run migrations to create the cache tables:
plain migrate
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 plain_cache-0.20.2.tar.gz.
File metadata
- Download URL: plain_cache-0.20.2.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cac85ea9db04b824c73edc64abdfc63a772219f076127cd53ed3e04ee6d01624
|
|
| MD5 |
6b6be8a41dd458ba2c177c2e2186db45
|
|
| BLAKE2b-256 |
bc88295dd4156aabddd42eabb03a51483abfc0ef7f7d21fffa66175fa4ce8867
|
File details
Details for the file plain_cache-0.20.2-py3-none-any.whl.
File metadata
- Download URL: plain_cache-0.20.2-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee3d60d80f4b8ef840fbd2c33461adc61c462e64207b63128d78ccbda4456a89
|
|
| MD5 |
57d3ea1b362f167166cd7923e358bea0
|
|
| BLAKE2b-256 |
a9cb1fecd43be6b5242991c9ad962f4b820bb8e32135496388536fe167a17fa7
|