Cache object lookups in WebAPIResource.get_object.
Review Request #5906 — Created May 30, 2014 and submitted — Latest diff uploaded
It's pretty common for different parts of a
WebAPIResource
subclass to
perform aget_object()
call either on itself or on another resource.
This will happen inget_queryset()
and in the permission-checking
functions. These checks are time-consuming and result in excess
database queries.The built-in
get_object()
now supports caching of these objects. The
caches are tied to the request, so any redundantget_object()
calls
taking place within that request will just use the original call's
result.
Djblets and Review Board unit tests pass.
Review Board unit tests gained nearly a 2 second increase in speed for
the API tests.Tested a few resources I suspected had redundant calls. Saw the query counts
drop.