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

24 lines
626 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:)
Gitlab::Redis::SharedState.with do |redis|
redis.set(merge_check.cache_key + ":#{VERSION}", result_hash.to_json, ex: EXPIRATION)
end
end
def retrieve_check(merge_check:)
Gitlab::Redis::SharedState.with do |redis|
Gitlab::Json.parse(redis.get(merge_check.cache_key + ":#{VERSION}"))
end
end
end
end
end
end