Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change semantics of
put
method for LRUCache objects
This changes the `LRUCache.put` method to provide a general way to insert an object into the cache. Previously, `LRUCache.put` wasn't sufficient for this as it appeared to only behave as a "touch" method (e.g. if the item wasn't already in the cache, it was a noop). This is useful to provide a way to "seed" the various caches. In a number of locations we construct items and put them in the DB, only to immediately load them back. We already have caches around these DB accesses to avoid multiple "gets" actually hitting the DB, but we can avoid the initial "get" missing in many cases by seeding the associated cache when we put the item into the DB. An example of this is chrdicts and the chrdict cache, where it's common to call `addChange` followed by `getChange`. This results in two DB accesses when it really only needs to be one.
- Loading branch information
Showing
4 changed files
with
13 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,9 @@ def mkref(x): | |
d.addCallback(mkref) | ||
return d | ||
|
||
def put(self, key, val): | ||
pass | ||
|
||
|
||
class FakeCaches(object): | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters