Add ReactiveCacheSetCache
What does this MR do?
This adds a Set
cache designed for holding ReactiveCaching
keys for a given resource.
When we cache requests with ReactiveCache, we often cache many keys for a single endpoint depending on which paramaters are given. An example is the ErrorTracking list, where we cache params such as search, sort, page etc. Therefore for a single Error tracking list we can have multiple keys, each with their own response stored in the cache:
"cache:gitlab:error_tracking_project_error_tracking_setting:22:list_issues:{\"issue_status\"=>\"unresolved\", \"limit\"=>20, \"search_term\"=>\"Renderer\", \"sort\"=>\"last_seen\", \"cursor\"=>nil}"
"cache:gitlab:error_tracking_project_error_tracking_setting:22:list_issues:{\"issue_status\"=>\"unresolved\", \"limit\"=>20, \"search_term\"=>nil, \"sort\"=>\"first_seen\", \"cursor\"=>nil}"
"cache:gitlab:error_tracking_project_error_tracking_setting:22:list_issues:{\"issue_status\"=>\"unresolved\", \"limit\"=>20, \"search_term\"=>nil, \"sort\"=>\"last_seen\", \"cursor\"=>nil}"
- etc...
When ignoring/resolving a Sentry error we need to clear the all the caches for the resource (delete all the keys above). We initially tried this using Rails.cache.delete_matched
, but it was not performant.
With this approach, we keep a Set of cache keys. To expire the ReactiveCache completely for a resource, we:
- Iterate over the keys in the Set
- For each one, delete the keys from Redis
Does this MR meet the acceptance criteria?
Conformity
Edited by Sean Arnold