akvo.cache.prepo module
- class akvo.cache.prepo.PrePoPickler[source]
Bases:
object
Helps prepare an object pre-pickle and an object post-pickle
Some objects take an inordinate amount of time to pickle, which negates the benefits of caching. In some cases however, it can help to pickle only certain parts of the object from whence the entire object
can then later be built at a lower cost.
- class akvo.cache.prepo.QuerysetPrePo[source]
Bases:
PrePoPickler
The queryset’s model and SQL query are pickled instead of the results from the executed query.
(Un-)Pickling speed of Querysets is very unstable. It can often be more expensive to pickle and unpickle than simply execute it.
In cases where building the queryset itself is expensive, it can be worth caching the resulting queryset.
- classmethod expand(reduction: QuerysetReduction) QuerySet [source]
Rebuilds a fresh Queryset from a reduction
- classmethod reduce(queryset: QuerySet) QuerysetReduction | None [source]
Extracts the full, importable path of the Queryset’s model + the SQL query