Commit 19440e67 authored by Gabriel Mazetto's avatar Gabriel Mazetto

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.
parent 624ec622
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment