BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
4eda09e3
Unverified
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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
cacheable_attributes.rb
app/models/concerns/cacheable_attributes.rb
+4
-0
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,8 +25,12 @@ module CacheableAttributes
end
def
cached
if
RequestStore
.
active?
RequestStore
[
:"
#{
name
}
_cached_attributes"
]
||=
retrieve_from_cache
else
retrieve_from_cache
end
end
def
retrieve_from_cache
record
=
Rails
.
cache
.
read
(
cache_key
)
...
...
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