diff options
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r-- | app/models/repository.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 587b71315c2..ee71e9603eb 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -1008,7 +1008,7 @@ class Repository def ancestor?(ancestor_id, descendant_id) return false if ancestor_id.nil? || descendant_id.nil? - cache_key = "ancestor:#{ancestor_id}:#{descendant_id}" + cache_key = ancestor_cache_key(ancestor_id, descendant_id) request_store_cache.fetch(cache_key) do cache.fetch(cache_key) do raw_repository.ancestor?(ancestor_id, descendant_id) @@ -1016,6 +1016,12 @@ class Repository end end + def expire_ancestor_cache(ancestor_id, descendant_id) + cache_key = ancestor_cache_key(ancestor_id, descendant_id) + request_store_cache.expire(cache_key) + cache.expire(cache_key) + end + def clone_as_mirror(url, http_authorization_header: "", resolved_address: "") import_repository(url, http_authorization_header: http_authorization_header, mirror: true, resolved_address: resolved_address) end @@ -1236,6 +1242,10 @@ class Repository private + def ancestor_cache_key(ancestor_id, descendant_id) + "ancestor:#{ancestor_id}:#{descendant_id}" + end + # TODO Genericize finder, later split this on finders by Ref or Oid # https://gitlab.com/gitlab-org/gitlab/issues/19877 def find_commit(oid_or_ref) |