Skip to content

Draft: Redesign cache store class with metrics

Vasilii Iakliushin requested to merge redesign_cache_store_with_metrics into master

What does this MR do and why?

Problem

Previous implementation of Gitlab::Cache::Client has several limitations:

  1. It requires to define cache_identifier per cache instance not per usage.
  2. 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.

Edited by Vasilii Iakliushin

Merge request reports