Asymmetrically cache Repository existence state
We've had lots of problems with needing to clear the state of Repository empty?
, exists?
, and has_visible_content?
caches manually, both for customers and for users of GitLab.com. As @jacobvosmaer-gitlab says well in https://gitlab.com/gitlab-org/gitlab-ce/issues/43882#note_61724936:
We could also cache these methods asymmetrically.
It's rare for a repository to be empty, have no visible content, or not exist. So we could cache those (negative) conditions in RequestStore. The positive conditions we could cache in Rails.cache, with its usual long TTL.
I think not caching these at all is likely to backfire.
Proposal:
- We improve
Repository#cache_method
to include a different TTL time forfalse
results
/cc: @DouweM, @smcgivern, @jramsay