debian-mirror-gitlab/lib/gitlab/merge_requests/mergeability/redis_interface.rb
2023-01-13 15:02:22 +05:30

27 lines
735 B
Ruby

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