summaryrefslogtreecommitdiff
path: root/app/models/concerns/repositories/can_housekeep_repository.rb
blob: 946f82c5f36509161d1fa8cf4cfac792153b9e37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

module Repositories
  module CanHousekeepRepository
    extend ActiveSupport::Concern

    def pushes_since_gc
      Gitlab::Redis::SharedState.with { |redis| redis.get(pushes_since_gc_redis_shared_state_key).to_i }
    end

    def increment_pushes_since_gc
      Gitlab::Redis::SharedState.with { |redis| redis.incr(pushes_since_gc_redis_shared_state_key) }
    end

    def reset_pushes_since_gc
      Gitlab::Redis::SharedState.with { |redis| redis.del(pushes_since_gc_redis_shared_state_key) }
    end

    def git_garbage_collect_worker_klass
      raise NotImplementedError
    end

    private

    def pushes_since_gc_redis_shared_state_key
      "#{self.class.name.underscore.pluralize}/#{id}/pushes_since_gc"
    end
  end
end