debian-mirror-gitlab/lib/gitlab/merge_requests/mergeability/redis_interface.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
735 B
Ruby
Raw Normal View History

2021-11-18 22:05:49 +05:30
# frozen_string_literal: true
module Gitlab
module MergeRequests
module Mergeability
class RedisInterface
EXPIRATION = 6.hours
VERSION = 1
def save_check(merge_check:, result_hash:)
2023-01-13 00:05:48 +05:30
with_redis do |redis|
2021-11-18 22:05:49 +05:30
redis.set(merge_check.cache_key + ":#{VERSION}", result_hash.to_json, ex: EXPIRATION)
end
end
def retrieve_check(merge_check:)
2023-01-13 00:05:48 +05:30
with_redis do |redis|
Gitlab::Json.parse(redis.get(merge_check.cache_key + ":#{VERSION}"), symbolize_keys: true)
2021-11-18 22:05:49 +05:30
end
end
2023-01-13 00:05:48 +05:30
def with_redis(&block)
Gitlab::Redis::Cache.with(&block) # rubocop:disable CodeReuse/ActiveRecord
end
2021-11-18 22:05:49 +05:30
end
end
end
end