Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
4eda09e3
Commit
4eda09e3
authored
May 29, 2018
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use RequestStore in CacheableAttributes.cached for greater performance
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
a886532c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
app/models/concerns/cacheable_attributes.rb
app/models/concerns/cacheable_attributes.rb
+5
-1
spec/models/concerns/cacheable_attributes_spec.rb
spec/models/concerns/cacheable_attributes_spec.rb
+9
-0
No files found.
app/models/concerns/cacheable_attributes.rb
View file @
4eda09e3
...
...
@@ -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
...
...
spec/models/concerns/cacheable_attributes_spec.rb
View file @
4eda09e3
...
...
@@ -177,6 +177,15 @@ describe CacheableAttributes do
end
end
end
it
'uses RequestStore in addition to Rails.cache'
,
:request_store
do
# Warm up the cache
create
(
:application_setting
).
cache!
expect
(
Rails
.
cache
).
to
receive
(
:read
).
with
(
ApplicationSetting
.
cache_key
).
once
.
and_call_original
2
.
times
{
ApplicationSetting
.
current
}
end
end
describe
'.cached'
,
:use_clean_rails_memory_store_caching
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment