2019-09-30 21:07:59 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module UsageDataCounters
|
|
|
|
module RedisCounter
|
|
|
|
def increment(redis_counter_key)
|
2019-10-12 21:52:04 +05:30
|
|
|
return unless Gitlab::CurrentSettings.usage_ping_enabled
|
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
Gitlab::Redis::SharedState.with { |redis| redis.incr(redis_counter_key) }
|
|
|
|
end
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
def increment_by(redis_counter_key, incr)
|
|
|
|
return unless Gitlab::CurrentSettings.usage_ping_enabled
|
|
|
|
|
|
|
|
Gitlab::Redis::SharedState.with { |redis| redis.incrby(redis_counter_key, incr) }
|
|
|
|
end
|
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
def total_count(redis_counter_key)
|
|
|
|
Gitlab::Redis::SharedState.with { |redis| redis.get(redis_counter_key).to_i }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|