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
0
Merge Requests
0
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
Kazuhiko Shiozaki
gitlab-ce
Commits
f81b55bd
Commit
f81b55bd
authored
Feb 20, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'refactor-scan' into 'master'
Improve readability of 'rake cache:clear' code See merge request !2892
parents
c352aaa0
44e4f070
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
6 deletions
+5
-6
lib/tasks/cache.rake
lib/tasks/cache.rake
+5
-6
No files found.
lib/tasks/cache.rake
View file @
f81b55bd
namespace
:cache
do
namespace
:cache
do
CLEAR_BATCH_SIZE
=
1000
CLEAR_BATCH_SIZE
=
1000
# The more the faster, but having too many can crash Ruby
REDIS_SCAN_START_STOP
=
'0'
# Magic value, see http://redis.io/commands/scan
REDIS_SCAN_START_STOP
=
'0'
# Magic value, see http://redis.io/commands/scan
desc
"GitLab | Clear redis cache"
desc
"GitLab | Clear redis cache"
task
:clear
=>
:environment
do
task
:clear
=>
:environment
do
redis_store
=
Rails
.
cache
.
instance_variable_get
(
:@data
)
redis_store
=
Rails
.
cache
.
instance_variable_get
(
:@data
)
cursor
=
[
REDIS_SCAN_START_STOP
,
[]]
cursor
=
REDIS_SCAN_START_STOP
loop
do
loop
do
cursor
=
redis_store
.
scan
(
cursor
,
keys
=
redis_store
.
scan
(
cursor
.
first
,
cursor
,
match:
"
#{
Gitlab
::
REDIS_CACHE_NAMESPACE
}
*"
,
match:
"
#{
Gitlab
::
REDIS_CACHE_NAMESPACE
}
*"
,
count:
CLEAR_BATCH_SIZE
count:
CLEAR_BATCH_SIZE
)
)
keys
=
cursor
.
last
redis_store
.
del
(
*
keys
)
if
keys
.
any?
redis_store
.
del
(
*
keys
)
if
keys
.
any?
break
if
cursor
.
first
==
REDIS_SCAN_START_STOP
break
if
cursor
==
REDIS_SCAN_START_STOP
end
end
end
end
end
end
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