2019-07-25 01:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-04 04:02:08 -04:00
|
|
|
module RedisHelpers
|
|
|
|
# config/README.md
|
|
|
|
|
|
|
|
# Usage: performance enhancement
|
|
|
|
def redis_cache_cleanup!
|
2021-07-19 02:08:44 -04:00
|
|
|
Gitlab::Redis::Cache.with(&:flushdb)
|
2018-05-04 04:02:08 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# Usage: SideKiq, Mailroom, CI Runner, Workhorse, push services
|
|
|
|
def redis_queues_cleanup!
|
2021-07-19 02:08:44 -04:00
|
|
|
Gitlab::Redis::Queues.with(&:flushdb)
|
2018-05-04 04:02:08 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# Usage: session state, rate limiting
|
|
|
|
def redis_shared_state_cleanup!
|
2021-07-19 02:08:44 -04:00
|
|
|
Gitlab::Redis::SharedState.with(&:flushdb)
|
2018-05-04 04:02:08 -04:00
|
|
|
end
|
2021-06-10 11:10:14 -04:00
|
|
|
|
|
|
|
# Usage: CI trace chunks
|
|
|
|
def redis_trace_chunks_cleanup!
|
2021-07-19 02:08:44 -04:00
|
|
|
Gitlab::Redis::TraceChunks.with(&:flushdb)
|
2021-06-10 11:10:14 -04:00
|
|
|
end
|
2021-09-30 14:11:31 -04:00
|
|
|
|
|
|
|
# Usage: rate limiting state (for Rack::Attack)
|
|
|
|
def redis_rate_limiting_cleanup!
|
|
|
|
Gitlab::Redis::RateLimiting.with(&:flushdb)
|
|
|
|
end
|
2021-10-15 11:10:09 -04:00
|
|
|
|
|
|
|
# Usage: session state
|
|
|
|
def redis_sessions_cleanup!
|
|
|
|
Gitlab::Redis::Sessions.with(&:flushdb)
|
|
|
|
end
|
2021-12-17 10:13:39 -05:00
|
|
|
|
|
|
|
# Usage: reset cached instance config
|
|
|
|
def redis_clear_raw_config!(instance_class)
|
|
|
|
instance_class.remove_instance_variable(:@_raw_config)
|
|
|
|
rescue NameError
|
|
|
|
# raised if @_raw_config was not set; ignore
|
|
|
|
end
|
2018-05-04 04:02:08 -04:00
|
|
|
end
|