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

redis_interface.rb « mergeability « merge_requests « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b0e739f91ff06155dd68e048f84bf3ada0c062c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 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::Cache.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::Cache.with do |redis|
            Gitlab::Json.parse(redis.get(merge_check.cache_key + ":#{VERSION}"))
          end
        end
      end
    end
  end
end