diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-07 21:09:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-07 21:09:45 +0300 |
commit | 413119517cca6a47f52d77b49ae3cab4cdaf9884 (patch) | |
tree | 046eb80cb92bb948cd49a99b7c34bf8dc6884c4f /lib/gitlab/repository_set_cache.rb | |
parent | 40b78ea2b6f5f0ef730c2cd811911be3449562e6 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/repository_set_cache.rb')
-rw-r--r-- | lib/gitlab/repository_set_cache.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/gitlab/repository_set_cache.rb b/lib/gitlab/repository_set_cache.rb index def7b58a852..f73ac628bce 100644 --- a/lib/gitlab/repository_set_cache.rb +++ b/lib/gitlab/repository_set_cache.rb @@ -49,5 +49,20 @@ module Gitlab write(key, yield) end + + # Searches the cache set using SSCAN with the MATCH option. The MATCH + # parameter is the pattern argument. + # See https://redis.io/commands/scan#the-match-option for more information. + # Returns an Enumerator that enumerates all SSCAN hits. + def search(key, pattern, &block) + full_key = cache_key(key) + + with do |redis| + exists = redis.exists(full_key) + write(key, yield) unless exists + + redis.sscan_each(full_key, match: pattern) + end + end end end |