summaryrefslogtreecommitdiff
path: root/lib/gitlab/usage_data_counters/redis_counter.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/usage_data_counters/redis_counter.rb')
-rw-r--r--lib/gitlab/usage_data_counters/redis_counter.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/gitlab/usage_data_counters/redis_counter.rb b/lib/gitlab/usage_data_counters/redis_counter.rb
new file mode 100644
index 00000000000..123b8e1bef1
--- /dev/null
+++ b/lib/gitlab/usage_data_counters/redis_counter.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module UsageDataCounters
+ module RedisCounter
+ def increment
+ Gitlab::Redis::SharedState.with { |redis| redis.incr(redis_counter_key) }
+ end
+
+ def total_count
+ Gitlab::Redis::SharedState.with { |redis| redis.get(redis_counter_key).to_i }
+ end
+
+ def redis_counter_key
+ raise NotImplementedError
+ end
+ end
+ end
+end