Skip to content

Fix caching logic for protected branches

Problem

Protected branches cache depends on a project cache key. But the cache key updates for every new issue, merge request and push to the project. That triggers a creation of new protected branches cache without removing the old versions of it.

As a result, we generate lots of cache keys that get stale quickly.

Proposal

  • Use a better strategy for caching. As an option, we can refresh the cache only when protected branches are changed.
  • Clean-up stale cache keys

Feature flags

  • hash_based_cache_for_protected_branches - enables the new caching implementation (but by default it's in dry-run mode)
  • rely_on_protected_branches_cache - requires hash_based_cache_for_protected_branches to be enabled and controls the dry-run mode.
hash_based_cache_for_protected_branches rely_on_protected_branches_cache Result
false false Use the old cache
false true Use the old cache
true false Use the new cache (dry-run: true)
true true Use the new cache (dry-run: false)
Edited by Vasilii Iakliushin