zulip/docs/subsystems
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
..
accessibility.md docs: Reorganize sections and pages about contributing to Zulip. 2022-08-25 11:24:57 -07:00
analytics.md docs: Fix outdated description of where stats views are. 2023-03-02 13:38:08 -08:00
api-release-checklist.md docs: Clean redundant relative links. 2022-02-24 16:12:18 -08:00
billing.md docs: Add missing space to compound verbs “back up”, “log in”, etc. 2022-02-07 19:20:54 -08:00
caching.md per-request caches: Add per_request_cache library. 2023-08-11 11:09:34 -07:00
client.md docs: Clean redundant relative links. 2022-02-24 16:12:18 -08:00
dependencies.md dependencies: Switch to pnpm. 2023-03-20 15:48:29 -07:00
django-upgrades.md docs: Apply sentence single-spacing from Prettier. 2021-09-08 12:06:24 -07:00
email.md email: Replace `uri` with `url` in templates and backend. 2023-04-26 16:37:16 -07:00
emoji.md settings: Explain that Google blob emojis are deprecated. 2022-10-04 12:29:35 -07:00
events-system.md docs: Rename "private message" -> "direct message". 2023-06-23 14:36:16 -07:00
full-text-search.md docs: Rename "operators" to "filters". 2022-12-09 13:52:13 -08:00
hashchange-system.md docs: Rename "private message" -> "direct message". 2023-06-23 14:36:16 -07:00
hotspots.md web: Move web app to ‘web’ directory. 2023-02-23 16:04:17 -08:00
html-css.md docs: Provide an example of dynamic styling. 2023-05-24 12:31:11 -07:00
index.md docs: Reorganize sections and pages about contributing to Zulip. 2022-08-25 11:24:57 -07:00
input-pills.md web: Move web app to ‘web’ directory. 2023-02-23 16:04:17 -08:00
logging.md error_notify: Remove custom email error reporting handler. 2023-07-20 11:00:09 -07:00
management-commands.md actions: Delete zerver.lib.actions. 2022-04-14 17:14:38 -07:00
markdown.md node_tests: Move to web/tests. 2023-02-23 16:04:17 -08:00
notifications.md web: Move web app to ‘web’ directory. 2023-02-23 16:04:17 -08:00
performance.md docs: Update production docs for local S3 caching. 2023-05-01 11:28:08 -07:00
pointer.md docs: Rename "private message" -> "direct message". 2023-06-23 14:36:16 -07:00
presence.md web: Move web app to ‘web’ directory. 2023-02-23 16:04:17 -08:00
queuing.md run-dev: Drop .py from script name. 2023-03-03 18:02:37 -08:00
realms.md docs: Move OPEN_REALM_CREATION doc section to multiple-organizations.md. 2022-10-31 17:56:45 -07:00
release-checklist.md docs: Update Transifex URLs. 2023-06-12 17:38:41 -07:00
schema-migrations.md docs: Document handling noop migrations. 2022-10-31 14:15:00 -07:00
sending-messages.md docs: Rename "private message" -> "direct message". 2023-06-23 14:36:16 -07:00
settings.md contributor docs: Rename "Upgrade or modify Zulip" -> "Upgrade Zulip". 2023-01-27 12:41:56 -08:00
slash-commands.md web: Move web app to ‘web’ directory. 2023-02-23 16:04:17 -08:00
typing-indicators.md docs: Rename "private message" -> "direct message". 2023-06-23 14:36:16 -07:00
unread_messages.md docs: Remove legacy references to "topic" as "subject". 2022-10-04 11:59:23 -07:00
widgets.md web: Move web app to ‘web’ directory. 2023-02-23 16:04:17 -08:00