This method is called at least on every issue show page and is currently implemented as follows:
def external_issue_tracker return @external_issue_tracker if defined?(@external_issue_tracker) @external_issue_tracker ||= services.issue_trackers.active.without_defaults.first end
While the output is memoized this is not persisted between requests meaning that only repeated calls in the same request will benefit from it. Meanwhile the type of issue tracker used by a project won't change very often.
There are two caching based solutions to solve this problem:
- Cache the output in Redis, flushing it whenever an issue tracker service is added.
- Cache the state as a boolean in the
projects.external_issue_tracker), updating it whenever a new issue tracker service is added
Option 1 has the flaw that currently our Redis keys automatically expire after 2 weeks, resulting in this data being rebuilt 2 weeks after being initially built. Option 2 never is probably the best as it's not automatically expired.
Note: When I refer to "issue tracker service is added" I mean an issue tracker service that would change whatever
services.issue_trackers.active.without_defaults.first will return.