2019-07-16 09:12:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module UsageDataCounters
|
|
|
|
module RedisCounter
|
2019-07-17 19:45:35 -04:00
|
|
|
def increment(redis_counter_key)
|
2021-08-12 08:11:05 -04:00
|
|
|
return unless ::ServicePing::ServicePingSettings.enabled?
|
2019-07-19 13:04:33 -04:00
|
|
|
|
2019-07-16 09:12:37 -04:00
|
|
|
Gitlab::Redis::SharedState.with { |redis| redis.incr(redis_counter_key) }
|
|
|
|
end
|
|
|
|
|
2020-09-02 17:10:43 -04:00
|
|
|
def increment_by(redis_counter_key, incr)
|
2021-08-12 08:11:05 -04:00
|
|
|
return unless ::ServicePing::ServicePingSettings.enabled?
|
2020-09-02 17:10:43 -04:00
|
|
|
|
|
|
|
Gitlab::Redis::SharedState.with { |redis| redis.incrby(redis_counter_key, incr) }
|
|
|
|
end
|
|
|
|
|
2019-07-17 19:45:35 -04:00
|
|
|
def total_count(redis_counter_key)
|
2019-07-16 09:12:37 -04:00
|
|
|
Gitlab::Redis::SharedState.with { |redis| redis.get(redis_counter_key).to_i }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|