Skip to content

Use a shorter TTL for Repository#exists? caching

Jacob Vosmaer requested to merge repository-exists-cache-short-ttl into master

What does this MR do?

Use a custom expiry time for the cached value of Repository#exists?.

Are there points in the code the reviewer needs to double check?

Why was this MR needed?

The default cache expiry time is two weeks (the expiry time of Rails.cache). This means that if we get false negatives in the cache for Repository#exists? (this has happened) and if there are bugs that prevent this false negative from being removed from the cache (this has also happened), the repository is effectively gone for two weeks or until administrators intervene by manipulating the Redis cache behind the scenes.

In this change we add a custom Redis cache mechanism for Repository#exists? with an expiry time of 10 minutes. This is an arbitrary value I came up with which I think is long enough for the cache to have a significant benefit and short enough so that in the case of cache poisoning the nuisance for users is of a limited scope.

Screenshots (if relevant)

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Edited by Jacob Vosmaer

Merge request reports