Files
gitlab-foss/lib/gitlab/redis/cursor_store.rb
2025-06-02 15:11:59 +00:00

37 lines
690 B
Ruby

# frozen_string_literal: true
module Gitlab
module Redis
class CursorStore
def initialize(namespace, ttl: 1.hour)
@namespace = namespace
@ttl = ttl.to_i
end
def commit(payload)
Gitlab::Redis::SharedState.with do |redis|
redis.set(cache_key, payload.to_json, ex: ttl)
end
end
def cursor
Gitlab::Json.parse(value_on_redis).to_h
end
private
attr_reader :namespace, :ttl
def cache_key
"CursorStore:#{namespace}"
end
def value_on_redis
Gitlab::Redis::SharedState.with do |redis|
redis.get(cache_key)
end
end
end
end
end