diff options
| author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-01 18:13:56 +0000 |
|---|---|---|
| committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-01 18:13:56 +0000 |
| commit | 1769b59b9fd05325e3016b1a53a82ae6cf56adb5 (patch) | |
| tree | a7e81e0c94fce5cc033e802d53d0c08d833fc87d /lib/feature | |
| parent | 05003789d95f2f5d28a2f018d9e1b51ad7ab983c (diff) | |
| download | gitlab-ce-1769b59b9fd05325e3016b1a53a82ae6cf56adb5.tar.gz | |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/feature')
| -rw-r--r-- | lib/feature/active_support_cache_store_adapter.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/feature/active_support_cache_store_adapter.rb b/lib/feature/active_support_cache_store_adapter.rb new file mode 100644 index 00000000000..30e418da44e --- /dev/null +++ b/lib/feature/active_support_cache_store_adapter.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +# rubocop:disable Gitlab/NamespacedClass +# This class was already nested this way before moving to a separate file +class Feature + class ActiveSupportCacheStoreAdapter < Flipper::Adapters::ActiveSupportCacheStore + def enable(feature, gate, thing) + return super unless Feature.enabled?(:feature_flags_cache_stale_read_fix, default_enabled: :yaml) + + result = @adapter.enable(feature, gate, thing) + @cache.write(key_for(feature.key), @adapter.get(feature), @write_options) + result + end + + def disable(feature, gate, thing) + return super unless Feature.enabled?(:feature_flags_cache_stale_read_fix, default_enabled: :yaml) + + result = @adapter.disable(feature, gate, thing) + @cache.write(key_for(feature.key), @adapter.get(feature), @write_options) + result + end + + def remove(feature) + return super unless Feature.enabled?(:feature_flags_cache_stale_read_fix, default_enabled: :yaml) + + result = @adapter.remove(feature) + @cache.delete(FeaturesKey) + @cache.write(key_for(feature.key), {}, @write_options) + result + end + end +end +# rubocop:disable Gitlab/NamespacedClass |
