Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-06-17 13:07:47 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-17 13:07:47 +0300
commitd670c3006e6e44901bce0d53cc4768d1d80ffa92 (patch)
tree8f65743c232e5b76850c4cc264ba15e1185815ff /lib/gitlab/safe_request_store.rb
parenta5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (diff)
Add latest changes from gitlab-org/gitlab@14-0-stable-ee
Diffstat (limited to 'lib/gitlab/safe_request_store.rb')
-rw-r--r--lib/gitlab/safe_request_store.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/gitlab/safe_request_store.rb b/lib/gitlab/safe_request_store.rb
index d146913bdb3..664afd1cc21 100644
--- a/lib/gitlab/safe_request_store.rb
+++ b/lib/gitlab/safe_request_store.rb
@@ -20,6 +20,15 @@ module Gitlab
end
end
+ # Access to the backing storage of the request store. This returns an object
+ # with `[]` and `[]=` methods that does not discard values.
+ #
+ # This can be useful if storage is needed for a delimited purpose, and the
+ # forgetful nature of the null store is undesirable.
+ def self.storage
+ store.store
+ end
+
# This method accept an options hash to be compatible with
# ActiveSupport::Cache::Store#write method. The options are
# not passed to the underlying cache implementation because
@@ -27,5 +36,11 @@ module Gitlab
def self.write(key, value, options = nil)
store.write(key, value)
end
+
+ def self.delete_if(&block)
+ return unless RequestStore.active?
+
+ storage.delete_if { |k, v| block.call(k) }
+ end
end
end