Follow-up from "WIP: Use RequestStore to memoize Flipper features so that memoized values are cleared between requests"
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
The following discussion from gitlab-ce!19281 should be addressed:
-
@godfat started a discussion: Does it make sense to use
lib/gitlab/cache/request_cache.rbhere? Maybe like:class Feature singleton_class.extend Gitlab::Cache::RequestCache class << self request_cache def flipper Flipper.new(flipper_adapter).tap { |flip| flip.memoize = true } end end endI tried a bit, and we'll need a patch for it to work:
diff --git a/lib/gitlab/cache/request_cache.rb b/lib/gitlab/cache/request_cache.rb index ecc85f847d4..17d567fe4ed 100644 --- a/lib/gitlab/cache/request_cache.rb +++ b/lib/gitlab/cache/request_cache.rb @@ -77,7 +77,7 @@ module Gitlab end define_method(cache_key_method_name) do |args| - klass = self.class + klass = is_a?(Class) ? singleton_class : self.class instance_key = instance_exec(&klass.request_cache_key) if klass.request_cache_key
Edited by 🤖 GitLab Bot 🤖