diff options
author | Gabriel Mazetto <brodock@gmail.com> | 2018-11-16 04:56:27 +0100 |
---|---|---|
committer | Gabriel Mazetto <brodock@gmail.com> | 2018-11-16 16:22:53 +0100 |
commit | 19440e67225d41ff821a9e31f47d60fe7a1718c2 (patch) | |
tree | 63df7da4b0fad6e8124d626229643de67ddc435d /lib | |
parent | 624ec62238c1d26ef2745c1147edffde67a2b4e6 (diff) | |
download | gitlab-ce-19440e67225d41ff821a9e31f47d60fe7a1718c2.tar.gz |
Change project cache key to depend on ID instead of full path
Previously, project cache used as part of the namespace the `full_path`,
which included namespace and project slug.
That meant that anytime a project was renamed or transfered to a
different namespace, we would lose the existing cache. This is not
necessary, nor desired.
I've prefixed cache key with `project:` to make it easy to find in redis
if necessary as well as make it possible to purge all project related
cache.
I've also switched the cache key type to go after the initial namespace
and not before.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/repository_cache.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/gitlab/repository_cache.rb b/lib/gitlab/repository_cache.rb index 56007574b1b..6b0808f5304 100644 --- a/lib/gitlab/repository_cache.rb +++ b/lib/gitlab/repository_cache.rb @@ -7,13 +7,13 @@ module Gitlab def initialize(repository, extra_namespace: nil, backend: Rails.cache) @repository = repository - @namespace = "#{repository.full_path}:#{repository.project.id}" + @namespace = "project:#{repository.project.id}" @namespace = "#{@namespace}:#{extra_namespace}" if extra_namespace @backend = backend end def cache_key(type) - "#{type}:#{namespace}" + "#{namespace}:#{type}" end def expire(key) |