Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
e9819de1
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e9819de1
编写于
4月 10, 2017
作者:
N
Nick Thomas
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove the ClearDatabaseCacheWorker
上级
6647542c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
4 addition
and
70 deletion
+4
-70
app/models/concerns/cache_markdown_field.rb
app/models/concerns/cache_markdown_field.rb
+0
-25
app/workers/clear_database_cache_worker.rb
app/workers/clear_database_cache_worker.rb
+0
-24
config/sidekiq_queues.yml
config/sidekiq_queues.yml
+0
-1
lib/tasks/cache.rake
lib/tasks/cache.rake
+1
-6
spec/models/concerns/cache_markdown_field_spec.rb
spec/models/concerns/cache_markdown_field_spec.rb
+3
-14
未找到文件。
app/models/concerns/cache_markdown_field.rb
浏览文件 @
e9819de1
...
...
@@ -30,28 +30,6 @@ module CacheMarkdownField
end
end
# Dynamic registries don't really work in Rails as it's not guaranteed that
# every class will be loaded, so hardcode the list.
CACHING_CLASSES
=
%w[
AbuseReport
Appearance
ApplicationSetting
BroadcastMessage
Issue
Label
MergeRequest
Milestone
Namespace
Note
Project
Release
Snippet
]
.
freeze
def
self
.
caching_classes
CACHING_CLASSES
.
map
(
&
:constantize
)
end
def
skip_project_check?
false
end
...
...
@@ -107,9 +85,6 @@ module CacheMarkdownField
# a corresponding _html field. Any custom rendering options may be provided
# as a context.
def
cache_markdown_field
(
markdown_field
,
context
=
{})
raise
"Add
#{
self
}
to CacheMarkdownField::CACHING_CLASSES"
unless
CacheMarkdownField
::
CACHING_CLASSES
.
include?
(
self
.
to_s
)
cached_markdown_fields
[
markdown_field
]
=
context
html_field
=
cached_markdown_fields
.
html_field
(
markdown_field
)
...
...
app/workers/clear_database_cache_worker.rb
已删除
100644 → 0
浏览文件 @
6647542c
# This worker clears all cache fields in the database, working in batches.
class
ClearDatabaseCacheWorker
include
Sidekiq
::
Worker
include
DedicatedSidekiqQueue
BATCH_SIZE
=
1000
def
perform
CacheMarkdownField
.
caching_classes
.
each
do
|
kls
|
fields
=
kls
.
cached_markdown_fields
.
html_fields
clear_cache_fields
=
fields
.
each_with_object
({})
do
|
field
,
memo
|
memo
[
field
]
=
nil
end
Rails
.
logger
.
debug
(
"Clearing Markdown cache for
#{
kls
}
:
#{
fields
.
inspect
}
"
)
kls
.
unscoped
.
in_batches
(
of:
BATCH_SIZE
)
do
|
relation
|
relation
.
update_all
(
clear_cache_fields
)
end
end
nil
end
end
config/sidekiq_queues.yml
浏览文件 @
e9819de1
...
...
@@ -34,7 +34,6 @@
- [repository_fork, 1]
- [repository_import, 1]
- [project_service, 1]
- [clear_database_cache, 1]
- [delete_user, 1]
- [delete_merged_branches, 1]
- [authorized_projects, 1]
...
...
lib/tasks/cache.rake
浏览文件 @
e9819de1
...
...
@@ -21,12 +21,7 @@ namespace :cache do
end
end
desc
"GitLab | Clear database cache (in the background)"
task
db: :environment
do
ClearDatabaseCacheWorker
.
perform_async
end
task
all:
[
:db
,
:redis
]
task
all:
[
:redis
]
end
task
clear:
'cache:clear:redis'
...
...
spec/models/concerns/cache_markdown_field_spec.rb
浏览文件 @
e9819de1
require
'spec_helper'
describe
CacheMarkdownField
do
caching_classes
=
CacheMarkdownField
::
CACHING_CLASSES
CacheMarkdownField
::
CACHING_CLASSES
=
[
"ThingWithMarkdownFields"
].
freeze
# The minimum necessary ActiveModel to test this concern
class
ThingWithMarkdownFields
include
ActiveModel
::
Model
...
...
@@ -55,8 +52,6 @@ describe CacheMarkdownField do
end
end
CacheMarkdownField
::
CACHING_CLASSES
=
caching_classes
def
thing_subclass
(
new_attr
)
Class
.
new
(
ThingWithMarkdownFields
)
{
add_attr
(
new_attr
)
}
end
...
...
@@ -69,15 +64,9 @@ describe CacheMarkdownField do
subject
{
ThingWithMarkdownFields
.
new
(
foo:
markdown
,
foo_html:
html
)
}
describe
".attributes"
do
it
"excludes cache attributes"
do
expect
(
thing_subclass
(
:qux
).
new
.
attributes
.
keys
.
sort
).
to
eq
(
%w[bar baz foo qux]
)
end
end
describe
".cache_markdown_field"
do
it
"refuses to allow untracked classes"
do
expect
{
thing_subclass
(
:qux
).
__send__
(
:cache_markdown_field
,
:qux
)
}.
to
raise_error
(
RuntimeError
)
describe
'.attributes'
do
it
'excludes cache attributes'
do
expect
(
subject
.
attributes
.
keys
.
sort
).
to
eq
(
%w[bar baz foo]
)
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录