2019-07-16 13:12:37 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module UsageDataCounters
|
|
|
|
module RedisCounter
|
2019-07-17 23:45:35 +00:00
|
|
|
def increment(redis_counter_key)
|
2019-07-19 17:04:33 +00:00
|
|
|
return unless Gitlab::CurrentSettings.usage_ping_enabled
|
|
|
|
|
2019-07-16 13:12:37 +00:00
|
|
|
Gitlab::Redis::SharedState.with { |redis| redis.incr(redis_counter_key) }
|
|
|
|
end
|
|
|
|
|
2020-09-02 21:10:43 +00:00
|
|
|
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-07-17 23:45:35 +00:00
|
|
|
def total_count(redis_counter_key)
|
2019-07-16 13:12:37 +00:00
|
|
|
Gitlab::Redis::SharedState.with { |redis| redis.get(redis_counter_key).to_i }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|