#373 Avoid some unnecessary reloads in the cached functions
Merged by abompard. Opened by abompard.
abompard/fedora-hubs optimize-widget-caching  into  develop

Download 373.patch

Some functions retrieve a large amount of data to filter it later in the view. This is often the case with Datagrepper because the API does not allow complex filtering. As a result, the cache for this data does not need to be invalidated when a filter changes. This branch adds a variable so widgets can declare that.

There's also a commit allowing a cached function to declare what results should not be cached. For example if an HTTP request fails, it does not make sense to cache the empty result. This branch allows cached function to declare which values should not be cached (for example, None)

Neat, I didn't know about this

Is the intention here for this to be overridden by subclasses? If so, would it make more sense to make it part of the public interface by calling it should_cache?

Thanks for the review. About making _should_cache public, this method is indeed intended to be overridden by subclasses, but not called from the outer code. That's why I think that one underscore prefix (a conventional equivalent to "protected") is more appropriate that the public interface.
But I'm very open to discussion :-)

rebased

rebased

rebased

rebased

Pull-Request has been merged by abompard

Metadata