Module: Gitlab::UsageDataCounters::RedisCounter
- Included in:
- Gitlab::Usage::Metrics::Instrumentations::RedisMetric, Gitlab::Usage::Metrics::Instrumentations::TotalCountMetric, BaseCounter
- Defined in:
- lib/gitlab/usage_data_counters/redis_counter.rb
Instance Method Summary collapse
- #increment(redis_counter_key) ⇒ Object
- #increment_by(redis_counter_key, incr) ⇒ Object
- #total_count(redis_counter_key) ⇒ Object
Instance Method Details
#increment(redis_counter_key) ⇒ Object
6 7 8 9 10 |
# File 'lib/gitlab/usage_data_counters/redis_counter.rb', line 6 def increment(redis_counter_key) return unless ::ServicePing::ServicePingSettings.enabled? Gitlab::Redis::SharedState.with { |redis| redis.incr(redis_counter_key) } end |
#increment_by(redis_counter_key, incr) ⇒ Object
12 13 14 15 16 |
# File 'lib/gitlab/usage_data_counters/redis_counter.rb', line 12 def increment_by(redis_counter_key, incr) return unless ::ServicePing::ServicePingSettings.enabled? Gitlab::Redis::SharedState.with { |redis| redis.incrby(redis_counter_key, incr) } end |
#total_count(redis_counter_key) ⇒ Object
18 19 20 |
# File 'lib/gitlab/usage_data_counters/redis_counter.rb', line 18 def total_count(redis_counter_key) Gitlab::Redis::SharedState.with { |redis| redis.get(redis_counter_key).to_i } end |