summaryrefslogtreecommitdiff
path: root/lib/gitlab/usage_data_counters/redis_counter.rb
blob: 75d5a75e3a4364baee9579e0616b2615fad358bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

module Gitlab
  module UsageDataCounters
    module RedisCounter
      def increment(redis_counter_key)
        return unless Gitlab::CurrentSettings.usage_ping_enabled

        Gitlab::Redis::SharedState.with { |redis| redis.incr(redis_counter_key) }
      end

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