lp:~ubuntuone-pqm-team/django-modeldict/stable
- Get this branch:
- bzr branch lp:~ubuntuone-pqm-team/django-modeldict/stable
Branch merges
Branch information
Recent revisions
- 65. By Jeff Pollard <email address hidden>
-
Fix bug that caused us to pull down things every time
Summary:
So there was a bug in modeldict that caused the entire switch set to be pulled from cache any time `_cleanup()` was called on the modeldict, which happened every time the `request_finished` and `task_postrun` signals were fired. This was bad, as it means we have a cache `get()` calls to pull down the heavy switch set every single page load and celery task.The bug happened because `_cleanup()` reset the `_last_
checked_ for_remote_ changes` variable to `None`, effectively clobbering any information that the modeldict had to know what it's own personal `last_modified` timestamp was. Thus, it had no way to know if the remote cache had changed given its version. Practically, it caused this line of code to be run:
```
return int(cache_last_updated) > self._last_ checked_ for_remote_ changes
````cache_
last_updated` was the timestamp of the `last_updated` value in remote cache (when the switch set last changed), and `self._ last_checked_ for_remote_ changes` was `None`, reset by `_cleanup()`. No matter what valid `cache_ last_updated` value there is, comparing `any_value > None` is always `True`, so the modeldict thought that remote had changes and it pulled them down. The change was to add a separate `_local_
last_updated` instance variable that actually tracked the cached `last_updated` value. This leaves `_last_ checked_ for_remote_ changes` to only be used to track when the modeldict last synced its local cache with the remote one, and to be reset without blowing away the locally cached `last_updated` value. Test Plan: Existing tests, plus I added another test that asserts when cleanup is called it does not `get()` the whole switch set from the cache.
Reviewers: dcramer, ted
Reviewed By: dcramer
Differential Revision: http://
phabricator. local.disqus. net/D4150 - 64. By Jeff Pollard <email address hidden>
-
Refactor base.py to be a little easier to follow.
Summary:
My brain was exploding with all the terminology (cache, local_cache, _cache, etc), so I refactored the variable names and whatnot to be a little more semantic.NOTE: this does **not** fix the cache hit performance regression, but this was a dependency on it to make the logic actually read and make sense.
Test Plan: existing
Reviewers: dcramer
Reviewed By: dcramer
Differential Revision: http://
phabricator. local.disqus. net/D4132
Branch metadata
- Branch format:
- Branch format 7
- Repository format:
- Bazaar repository format 2a (needs bzr 1.16 or later)