Draft: Redesign cache store class with metrics
What does this MR do and why?
Problem
Previous implementation of Gitlab::Cache::Client has several limitations:
- It requires to define
cache_identifier
per cache instance not per usage. - Initialization of custom backends requires extra efforts
Solution
Include metrics classes into RedisCacheStore
. It allows to provide an additional parameters to Rails.cache.fetch
and Rails.cache.read
methods.
Additional attribute labels
permits users to define metadata for each redis call.
New cache interface
# Labels define default settings
Rails.cache.fetch('cache-key', labels: { cache_identifier: 'Class#cache_key', backing_resource: :gitaly }) do
'do work'
end
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Vasilii Iakliushin