gitlab-org--gitlab-foss/lib/gitlab/usage_data_counters/redis_counter.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
666 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module Gitlab
module UsageDataCounters
module RedisCounter
def increment(redis_counter_key)
return unless ::ServicePing::ServicePingSettings.enabled?
Gitlab::Redis::SharedState.with { |redis| redis.incr(redis_counter_key) }
end
def increment_by(redis_counter_key, incr)
return unless ::ServicePing::ServicePingSettings.enabled?
Gitlab::Redis::SharedState.with { |redis| redis.incrby(redis_counter_key, incr) }
end
def total_count(redis_counter_key)
Gitlab::Redis::SharedState.with { |redis| redis.get(redis_counter_key).to_i }
end
end
end
end