sqlmodel-cache
Transparent Redis caching for SQLModel — cache session.get() lookups with a single class attribute.
Installation
pip install sqlmodel-cache
# With async support:
pip install "sqlmodel-cache[async]"
Quick Example
import redis
from sqlmodel import Field, Session, SQLModel, create_engine
from sqlmodel_cache import CacheConfig, SQLModelCache
from sqlmodel_cache.transport import RedisSyncTransport
SQLModelCache.configure(
transport=RedisSyncTransport(redis.Redis.from_url("redis://localhost:6379")),
default_ttl=300,
)
class Hero(SQLModel, table=True):
__cache_config__ = CacheConfig(ttl=600)
id: int | None = Field(default=None, primary_key=True)
name: str = ""
engine = create_engine("sqlite:///heroes.db")
SQLModel.metadata.create_all(engine)
with Session(engine) as session:
hero = session.get(Hero, 1) # cache miss → queries DB
with Session(engine) as session:
hero = session.get(Hero, 1) # cache hit → returns from Redis
Documentation
Full documentation is available at emzelim.github.io/sqlmodel-cache.
License
MIT
Metadata
Release files for sqlmodel-cache 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sqlmodel_cache-0.1.1.tar.gz | 522.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sqlmodel_cache-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 540.3 kB
Release files / sqlmodel_cache-0.1.1.tar.gz
| Download URL | sqlmodel_cache-0.1.1.tar.gz |
|---|---|
| Size | 522.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
999fbcc3a6843aac7d19dd99649ccd5e70318e86283699a72898333aaee55738
|
|
BLAKE2b-256 checksum How to use checksums |
67a9ca0993891784b59bd594acbef19572fbe1ed6b84c203f0f73f2c03dff080
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 23, 2026.
Transparency logRelease files / sqlmodel_cache-0.1.1-py3-none-any.whl
| Download URL | sqlmodel_cache-0.1.1-py3-none-any.whl |
|---|---|
| Size | 18.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5e781dc38eed86ac6e8394c1c1a5d2646d27c1e233aa69158613709347588040
|
|
BLAKE2b-256 checksum How to use checksums |
df319f67a98394283c674bde861ecc5e9c432188b957a30af23fb889177ad701
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 23, 2026.
Transparency log