summaryrefslogtreecommitdiff
path: root/app/models/concerns/cacheable_attributes.rb
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-05-29 18:39:03 +0200
committerRémy Coutable <remy@rymai.me>2018-06-01 14:01:27 +0200
commit4eda09e3fbfe82fd1467e97cbc5bd085b91f257d (patch)
treedb0e8fbd141ff3252df450f60b9f1f5636c68489 /app/models/concerns/cacheable_attributes.rb
parenta886532cc04bfa7ec6885ea883889f6d138961bd (diff)
downloadgitlab-ce-4eda09e3fbfe82fd1467e97cbc5bd085b91f257d.tar.gz
Use RequestStore in CacheableAttributes.cached for greater performance
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/models/concerns/cacheable_attributes.rb')
-rw-r--r--app/models/concerns/cacheable_attributes.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/concerns/cacheable_attributes.rb b/app/models/concerns/cacheable_attributes.rb
index dd4fccc811d..d58d7165969 100644
--- a/app/models/concerns/cacheable_attributes.rb
+++ b/app/models/concerns/cacheable_attributes.rb
@@ -25,7 +25,11 @@ module CacheableAttributes
end
def cached
- retrieve_from_cache
+ if RequestStore.active?
+ RequestStore[:"#{name}_cached_attributes"] ||= retrieve_from_cache
+ else
+ retrieve_from_cache
+ end
end
def retrieve_from_cache