zulip/zerver/views/development
Steve Howell 51db22c86c per-request caches: Add per_request_cache library.
We have historically cached two types of values
on a per-request basis inside of memory:

    * linkifiers
    * display recipients

Both of these caches were hand-written, and they
both actually cache values that are also in memcached,
so the per-request cache essentially only saves us
from a few memcached hits.

I think the linkifier per-request cache is a necessary
evil. It's an important part of message rendering, and
it's not super easy to structure the code to just get
a single value up front and pass it down the stack.

I'm not so sure we even need the display recipient
per-request cache any more, as we are generally pretty
smart now about hydrating recipient data in terms of
how the code is organized. But I haven't done thorough
research on that hypotheseis.

Fortunately, it's not rocket science to just write
a glorified memoize decorator and tie it into key
places in the code:

    * middleware
    * tests (e.g. asserting db counts)
    * queue processors

That's what I did in this commit.

This commit definitely reduces the amount of code
to maintain. I think it also gets us closer to
possibly phasing out this whole technique, but that
effort is beyond the scope of this PR. We could
add some instrumentation to the decorator to see
how often we get a non-trivial number of saved
round trips to memcached.

Note that when we flush linkifiers, we just use
a big hammer and flush the entire per-request
cache for linkifiers, since there is only ever
one realm in the cache.
2023-08-11 11:09:34 -07:00
..
__init__.py
cache.py per-request caches: Add per_request_cache library. 2023-08-11 11:09:34 -07:00
camo.py coverage: Clean up coverage configuration. 2023-05-31 13:53:04 -07:00
dev_login.py dev_login: Pass realm as arg to select_related calls. 2023-07-20 10:44:39 -07:00
email_log.py welcome-emails: Separate followup_day1 email from other welcome emails. 2023-07-11 14:15:52 -07:00
integrations.py requirements: Upgrade Python requirements. 2023-07-19 16:14:59 -07:00
registration.py coverage: Clean up coverage configuration. 2023-05-31 13:53:04 -07:00