Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
d2e28e809773
Unverified
Commit
67ca5a53
authored
Jul 17, 2015
by
Dmitriy Zaporozhets
Browse files
Build missing cache items in background job after each push
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
9c9387a34702
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/models/repository.rb
View file @
d2e28e80
...
...
@@ -130,10 +130,29 @@ def size
cache
.
fetch
(
:size
)
{
raw_repository
.
size
}
end
def
expire_
cache
def
cache
_keys
%i(size branch_names tag_names commit_count graph_log
readme version contribution_guide changelog license)
.
each
do
|
key
|
readme version contribution_guide changelog license)
end
def
build_cache
cache_keys
.
each
do
|
key
|
unless
cache
.
exist?
(
key
)
send
(
key
)
end
end
end
def
expire_cache
cache_keys
.
each
do
|
key
|
cache
.
expire
(
key
)
end
end
def
rebuild_cache
cache_keys
.
each
do
|
key
|
cache
.
expire
(
key
)
send
(
key
)
end
end
...
...
app/services/git_push_service.rb
View file @
d2e28e80
...
...
@@ -61,6 +61,7 @@ def execute(project, user, oldrev, newrev, ref)
EventCreateService
.
new
.
push
(
project
,
user
,
@push_data
)
project
.
execute_hooks
(
@push_data
.
dup
,
:push_hooks
)
project
.
execute_services
(
@push_data
.
dup
,
:push_hooks
)
ProjectCacheWorker
.
perform_async
(
project
.
id
)
end
protected
...
...
app/services/git_tag_push_service.rb
View file @
d2e28e80
...
...
@@ -2,15 +2,15 @@ class GitTagPushService
attr_accessor
:project
,
:user
,
:push_data
def
execute
(
project
,
user
,
oldrev
,
newrev
,
ref
)
@
project
,
@user
=
project
,
user
project
.
repository
.
expire_cache
@project
,
@user
=
project
,
user
@push_data
=
build_push_data
(
oldrev
,
newrev
,
ref
)
EventCreateService
.
new
.
push
(
project
,
user
,
@push_data
)
project
.
execute_hooks
(
@push_data
.
dup
,
:tag_push_hooks
)
project
.
execute_services
(
@push_data
.
dup
,
:tag_push_hooks
)
project
.
repository
.
expire_cache
ProjectCacheWorker
.
perform_async
(
project
.
id
)
true
end
...
...
app/workers/project_cache_worker.rb
0 → 100644
View file @
d2e28e80
class
ProjectCacheWorker
include
Sidekiq
::
Worker
sidekiq_options
queue: :default
def
perform
(
project_id
)
Project
.
find
(
project_id
).
repository
.
build_cache
end
end
lib/repository_cache.rb
View file @
d2e28e80
...
...
@@ -18,4 +18,8 @@ def expire(key)
def
fetch
(
key
,
&
block
)
backend
.
fetch
(
cache_key
(
key
),
&
block
)
end
def
exist?
(
key
)
backend
.
exist?
(
key
)
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