summaryrefslogtreecommitdiff
path: root/app/models/concerns/cacheable_attributes.rb
diff options
context:
space:
mode:
authorReuben Pereira <rpereira@gitlab.com>2019-08-07 18:40:36 +0000
committerStan Hu <stanhu@gmail.com>2019-08-07 18:40:36 +0000
commitaf4a597d3fb687ed2841bb755403f66cf131bdff (patch)
tree45b6188b5a67d4372b4073c41a420119d6300a89 /app/models/concerns/cacheable_attributes.rb
parentd02003cf951692cc243b7ee512de2139e99f0c4c (diff)
downloadgitlab-ce-af4a597d3fb687ed2841bb755403f66cf131bdff.tar.gz
Save instance administration project id in DB
- This will make it easy to identify the project even if admins change the name of the project or move it.
Diffstat (limited to 'app/models/concerns/cacheable_attributes.rb')
-rw-r--r--app/models/concerns/cacheable_attributes.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/models/concerns/cacheable_attributes.rb b/app/models/concerns/cacheable_attributes.rb
index 53dff2adfc3..0c800621a55 100644
--- a/app/models/concerns/cacheable_attributes.rb
+++ b/app/models/concerns/cacheable_attributes.rb
@@ -5,6 +5,8 @@ module CacheableAttributes
included do
after_commit { self.class.expire }
+
+ private_class_method :request_store_cache_key
end
class_methods do
@@ -32,7 +34,11 @@ module CacheableAttributes
end
def cached
- Gitlab::SafeRequestStore[:"#{name}_cached_attributes"] ||= retrieve_from_cache
+ Gitlab::SafeRequestStore[request_store_cache_key] ||= retrieve_from_cache
+ end
+
+ def request_store_cache_key
+ :"#{name}_cached_attributes"
end
def retrieve_from_cache
@@ -58,6 +64,7 @@ module CacheableAttributes
end
def expire
+ Gitlab::SafeRequestStore.delete(request_store_cache_key)
cache_backend.delete(cache_key)
rescue
# Gracefully handle when Redis is not available. For example,