Cache area containments in memcached

Merged
#1644 · Created  · Last updated

Description

Caches the array of parent areas by descendant ID in memcached. There's not a good way to invalidate specific areas. If a parent changed, we'd have to invalidate the entries for every descendant, which is possible, but not a great idea since some areas have tens of thousands of descendants.

So, we'll just "clear" the entire containment cache for every change that would affect it (an area-area part-of relationship is added, updated, or removed, or an area is removed, merged, or has its type change). But these occurrences are fairly infrequent, I think, and when they do happen, the area_containment view only needs to be queried by descendant (as it happens now), not by parent.

"Clear" is in quotes there because you can't delete memcached keys by a namespace or pattern. Here we just change the namespace itself, and the old items eventually go away unused.

The cache namespace key is stored in redis as opposed to memcached so that it doesn't get removed by any LRU algorithm.

Here are some timings I got loading the page for the United States:

Without patch: 5977.36 ms 5790.452 ms 6142.073 ms 5828.122 ms 6081.942 ms average: 5963.9898 ms With patch: 3937.182 ms 4128.295 ms 4250.156 ms 3978.24 ms 3992.474 ms average: 4057.2694 ms ----------- difference: 1906.7204000000002 ms

0 attachments

0 comments

Loading commits...