summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/processable.rb6
-rw-r--r--app/models/concerns/reactive_caching.rb23
-rw-r--r--app/models/error_tracking/project_error_tracking_setting.rb6
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