cachely ⚡
Simple in-memory caching with TTL support for Python.
Installation
pip install cachely
Usage
Decorator
from cachely import cache
@cache(ttl=300) # Cache for 5 minutes
def expensive_computation(x):
return x ** 100
@cache(ttl=60, key_prefix="user")
def get_user(user_id):
return database.fetch_user(user_id)
Manual Cache
from cachely import Cache
cache = Cache()
# Set with TTL
cache.set("key", "value", ttl=300)
# Get value
value = cache.get("key", default=None)
# Delete
cache.delete("key")
# Clear all
cache.clear()
Features
- 🕐 TTL (time-to-live) support
- 🔒 Thread-safe operations
- 🎯 Function decorator
- 🧹 Automatic cleanup of expired entries
- 📊 Cache info and stats
API
Decorator Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
ttl |
int | None | Seconds until expiration |
key_prefix |
str | None | Prefix for cache keys |
Cache Methods
| Method | Description |
|---|---|
get(key, default) |
Get cached value |
set(key, value, ttl) |
Set cached value |
delete(key) |
Delete cached value |
clear() |
Clear all cache |
cleanup() |
Remove expired entries |
size() |
Number of cached items |
License
MIT
Metadata
Release files for pycachely-rj 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pycachely_rj-1.0.0.tar.gz | 3.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pycachely_rj-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.0 kB
Release files / pycachely_rj-1.0.0.tar.gz
| Download URL | pycachely_rj-1.0.0.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b4ca58cb50445983e4e59457501a9fe253c072aae2501ce6d3c52058ff3e649c
|
|
BLAKE2b-256 checksum How to use checksums |
c2df8def9d79bb44e4a98b10a9b476be429e3a07c8a444869416640c9d7ced00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / pycachely_rj-1.0.0-py3-none-any.whl
| Download URL | pycachely_rj-1.0.0-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4a0efd188460578a905f42d1ae2f67989b1952df13cef2273026f241bd809b01
|
|
BLAKE2b-256 checksum How to use checksums |
4e249be90ffe791add4a4fb030b51c2824dec503a3374008d82f2d193e8c4cfe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|