Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

refactor use of cache #42

Merged
merged 2 commits into from Apr 9, 2014

Conversation

Projects
None yet
2 participants
Owner

jacobb commented Apr 3, 2014

This simplifies how cache is handled. Removes the responsibility of calculating keys from the response from the backend and moves it to the engine. This will make soon future additions of allowing objects calculate their own key, "refresh" themselves (by bypassing the cache and resetting), and deleting themselves from the cache.

The above features are a quick addition once this overhaul is approved.

@ethurgood ethurgood and 1 other commented on an outdated diff Apr 4, 2014

nap/cache/django_cache.py
return cache.get(key)
- def set(self, response):
- key = self.get_cache_key(response)
+ def set(self, key, value, response=None):
timeout = self.get_timeout(response)
return cache.set(key, response, timeout)
@ethurgood

ethurgood Apr 4, 2014

Should this be:
return cache.set(key, value, timeout)
?

@jacobb

jacobb Apr 4, 2014

Owner

Wow, that was stupid. Yeah, good catch.

@ethurgood ethurgood and 1 other commented on an outdated diff Apr 4, 2014

if not headers:
headers = {}
self.headers = headers
+ self.request_method = request_method
+
+ @property
+ def use_cache(self):
+ """
+ use_cache must be explicitely set to False to bypass the cache.
+ This is usually done in the engine classes' get_from_cache method
+ """
+ if self._use_cache is False:
@ethurgood

ethurgood Apr 4, 2014

return self._use_cache is not False

?

@jacobb

jacobb Apr 4, 2014

Owner

good catch

I don't see a way to approve, so this comment counts as my approval.

jacobb added a commit that referenced this pull request Apr 9, 2014

@jacobb jacobb merged commit 39379b1 into master Apr 9, 2014

@jacobb jacobb deleted the cache2.0 branch Apr 9, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment