diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-07-17 15:50:03 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-07-17 15:50:03 +0300 |
commit | 67ca5a53f6df0c3d0f2598c777491c0548d76e50 (patch) | |
tree | adbd12e3b93c6f79335625dd2769843e15676341 /app/models | |
parent | 881fbe5070331f934fff3441dbc0e65377b030bf (diff) |
Build missing cache items in background job after each push
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/repository.rb | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 6262b5c4c92..bca14aa1a33 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -130,10 +130,29 @@ class Repository 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 |