Class: Gitlab::BackgroundMigration::FixIncoherentPackagesSizeOnProjectStatistics::BufferedCounter
- Inherits:
-
Object
- Object
- Gitlab::BackgroundMigration::FixIncoherentPackagesSizeOnProjectStatistics::BufferedCounter
- Defined in:
- lib/gitlab/background_migration/fix_incoherent_packages_size_on_project_statistics.rb
Constant Summary collapse
- WORKER_DELAY =
10.minutes
Instance Method Summary collapse
- #increment(amount) ⇒ Object
-
#initialize(stat) ⇒ BufferedCounter
constructor
A new instance of BufferedCounter.
- #key ⇒ Object
Constructor Details
#initialize(stat) ⇒ BufferedCounter
Returns a new instance of BufferedCounter.
95 96 97 |
# File 'lib/gitlab/background_migration/fix_incoherent_packages_size_on_project_statistics.rb', line 95 def initialize(stat) @stat = stat end |
Instance Method Details
#increment(amount) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/gitlab/background_migration/fix_incoherent_packages_size_on_project_statistics.rb', line 103 def increment(amount) Gitlab::Redis::SharedState.with do |redis| redis.incrby(key, amount) end FlushCounterIncrementsWorker.perform_in( WORKER_DELAY, 'ProjectStatistics', @stat.id, :packages_size ) end |
#key ⇒ Object
99 100 101 |
# File 'lib/gitlab/background_migration/fix_incoherent_packages_size_on_project_statistics.rb', line 99 def key "project:{#{@stat.project_id}}:counters:ProjectStatistics:#{@stat.id}:packages_size" end |