mirror of
https://github.com/GSA/notifications-api.git
synced 2026-03-02 06:50:08 -05:00
This commit proposes two types of caching to speed up the post notification processing time. Since every notification needs a template, if we can avoid going to the db to get the template then this should be faster. The first cache is an LRU cache, which means that, for a given `template_id`, `service_id` and `version` the app will go to memory rather than the database to get the template. This should be much faster, and we should be guaranteed that a combination of those three parameters should always return the same result. But, we don’t know the template version at the time of making the call. So this commit also adds another layer of caching to find the most recent version number of a template. Since this can be changed by other instances we need to cache it externally, so this cache uses Redis. Redis will be a lot slower than going to memory, but hopefully quicker than going to the database. By only caching the minimal amount of data possible in Redis (just the version as a number) we’re hopefully minimising the performance hit from going to an external service.