Class: Gitlab::BackgroundMigration::Redis::BackfillProjectPipelineStatusTtl
- Inherits:
-
Object
- Object
- Gitlab::BackgroundMigration::Redis::BackfillProjectPipelineStatusTtl
- Defined in:
- lib/gitlab/background_migration/redis/backfill_project_pipeline_status_ttl.rb
Overview
BackfillProjectPipelineStatusTtl cleans up keys written by Gitlab::Cache::Ci::ProjectPipelineStatus by adding a minimum 8-hour ttl to all keys. This either sets or extends the ttl of matching keys.
Instance Method Summary collapse
-
#perform(keys) ⇒ Object
rubocop:disable Migration/BackgroundMigrationBaseClass.
- #redis ⇒ Object
- #scan_match_pattern ⇒ Object
Instance Method Details
#perform(keys) ⇒ Object
rubocop:disable Migration/BackgroundMigrationBaseClass
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/gitlab/background_migration/redis/backfill_project_pipeline_status_ttl.rb', line 11 def perform(keys) # spread out deletes over a 4 hour period starting in 8 hours time ttl_duration = 10.hours.to_i ttl_jitter = 2.hours.to_i Gitlab::Instrumentation::RedisClusterValidator.allow_cross_slot_commands do Gitlab::Redis::CrossSlot::Pipeline.new(redis).pipelined do |pipeline| keys.each { |key| pipeline.expire(key, ttl_duration + rand(-ttl_jitter..ttl_jitter)) } end end end |
#redis ⇒ Object
27 28 29 |
# File 'lib/gitlab/background_migration/redis/backfill_project_pipeline_status_ttl.rb', line 27 def redis @redis ||= ::Redis.new(Gitlab::Redis::Cache.params) end |
#scan_match_pattern ⇒ Object
23 24 25 |
# File 'lib/gitlab/background_migration/redis/backfill_project_pipeline_status_ttl.rb', line 23 def scan_match_pattern "#{Gitlab::Redis::Cache::CACHE_NAMESPACE}:project:*:pipeline_status" end |