diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-26 18:08:56 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-26 18:08:56 +0300 |
commit | 17ab40ca089e1aef61a83f77ab6df62a72f6ce06 (patch) | |
tree | 8eb149293eee90ec2750b6ac5e46a111a806424e /app/models | |
parent | 66d4203791a01fdedf668a78818a229ea2c07aad (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/processable.rb | 6 | ||||
-rw-r--r-- | app/models/concerns/reactive_caching.rb | 23 | ||||
-rw-r--r-- | app/models/error_tracking/project_error_tracking_setting.rb | 6 |
3 files changed, 34 insertions, 1 deletions
diff --git a/app/models/ci/processable.rb b/app/models/ci/processable.rb index 6c080582cae..55518f32316 100644 --- a/app/models/ci/processable.rb +++ b/app/models/ci/processable.rb @@ -90,6 +90,12 @@ module Ci end end + def needs_attributes + strong_memoize(:needs_attributes) do + needs.map { |need| need.attributes.except('id', 'build_id') } + end + end + private def validate_scheduling_type? diff --git a/app/models/concerns/reactive_caching.rb b/app/models/concerns/reactive_caching.rb index 010e0018414..4b472cfdf45 100644 --- a/app/models/concerns/reactive_caching.rb +++ b/app/models/concerns/reactive_caching.rb @@ -52,6 +52,13 @@ module ReactiveCaching end end + def with_reactive_cache_set(resource, opts, &blk) + data = with_reactive_cache(resource, opts, &blk) + save_keys_in_set(resource, opts) if data + + data + end + # This method is used for debugging purposes and should not be used otherwise. def without_reactive_cache(*args, &blk) return with_reactive_cache(*args, &blk) unless Rails.env.development? @@ -65,6 +72,12 @@ module ReactiveCaching Rails.cache.delete(alive_reactive_cache_key(*args)) end + def clear_reactive_cache_set!(*args) + cache_key = full_reactive_cache_key(args) + + reactive_set_cache.clear_cache!(cache_key) + end + def exclusively_update_reactive_cache!(*args) locking_reactive_cache(*args) do key = full_reactive_cache_key(*args) @@ -86,6 +99,16 @@ module ReactiveCaching private + def save_keys_in_set(resource, opts) + cache_key = full_reactive_cache_key(resource) + + reactive_set_cache.write(cache_key, "#{cache_key}:#{opts}") + end + + def reactive_set_cache + Gitlab::ReactiveCacheSetCache.new(expires_in: reactive_cache_lifetime) + end + def refresh_reactive_cache!(*args) clear_reactive_cache!(*args) keep_alive_reactive_cache!(*args) diff --git a/app/models/error_tracking/project_error_tracking_setting.rb b/app/models/error_tracking/project_error_tracking_setting.rb index d328a609439..133850b6ab6 100644 --- a/app/models/error_tracking/project_error_tracking_setting.rb +++ b/app/models/error_tracking/project_error_tracking_setting.rb @@ -85,7 +85,7 @@ module ErrorTracking end def list_sentry_issues(opts = {}) - with_reactive_cache('list_issues', opts.stringify_keys) do |result| + with_reactive_cache_set('list_issues', opts.stringify_keys) do |result| result end end @@ -130,6 +130,10 @@ module ErrorTracking end end + def expire_issues_cache + clear_reactive_cache_set!('list_issues') + end + # http://HOST/api/0/projects/ORG/PROJECT # -> # http://HOST/ORG/PROJECT |