Flask-SQLAlchemy-Caching
This is a fork of iurisilvio's Flask-SQLAlchemy-Cache
A CachingQuery implementation to Flask using Flask-SQLAlchemy and Flask-Caching.
To start using caching queries, you just have to replace Flask-SQLAlchemy Model.query_class.
from flask_sqlalchemy import SQLAlchemy
from flask_sqlalchemy_caching import CachingQuery
from flask_caching import Cache
db = SQLAlchemy(app, query_class=CachingQuery)
cache = Cache(app)
After that, you can just make queries to a model YourModel:
from flask_sqlalchemy_caching import FromCache
# cache is a Flask-Caching instance imported for your app init
YourModel.query.options(FromCache(cache)).get()
You also have RelationshipCache to enable lazy loading relationships from
cache.
from sqlalchemy.orm import lazyload
from flask_sqlalchemy_caching import RelationshipCache
rc = RelationshipCache(YourModel.some_relationship, cache)
obj = YourModel.query.options(lazyload(YourModel.some_relationship), rc).get()
# make the query and cache the results for future queries
print(obj.some_relationship)
If there is a column in your table that is much more dynamic and you want to exclude it from being cached, try using a deferred query like:
YourModel.query.options(defer('crazy_column')).options(FromCache(cache)).get()
Take a look at Dogpile Caching example to more details about how
CachingQuery works. Most changes to their were made just to integrate it
with Flask, Flask-SQLAlchemy and Flask-Caching instead of Dogpile.
Metadata
Release files for Flask-SQLAlchemy-Caching 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Flask-SQLAlchemy-Caching-1.0.4.tar.gz | 5.1 kB | Without provenance | Details for Flask-SQLAlchemy-Caching-1.0.4.tar.gz |
Release files / Flask-SQLAlchemy-Caching-1.0.4.tar.gz
| Download URL | Flask-SQLAlchemy-Caching-1.0.4.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c3c0c86b3a42b0abbc0d64629670fa91244c23a3febde0f481cd612da2de18ab
|
|
BLAKE2b-256 checksum How to use checksums |
da3d20339dbe72c9acacd0191dfaf8af9e29aaf153fa8759a3a7ddaaaae9b03b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5
|
Security for Flask-SQLAlchemy-Caching 1.0.4
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.