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
Léo-Paul Géneau
gitlab-ce
Commits
44e4f070
Commit
44e4f070
authored
Feb 19, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve readability of 'rake cache:clear' code
parent
c21c8825
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 @
44e4f070
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
desc
"GitLab | Clear redis cache"
task
:clear
=>
:environment
do
redis_store
=
Rails
.
cache
.
instance_variable_get
(
:@data
)
cursor
=
[
REDIS_SCAN_START_STOP
,
[]]
cursor
=
REDIS_SCAN_START_STOP
loop
do
cursor
=
redis_store
.
scan
(
cursor
.
first
,
cursor
,
keys
=
redis_store
.
scan
(
cursor
,
match:
"
#{
Gitlab
::
REDIS_CACHE_NAMESPACE
}
*"
,
count:
CLEAR_BATCH_SIZE
)
keys
=
cursor
.
last
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
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