summaryrefslogtreecommitdiff
path: root/spec/lib/feature_spec.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-06-18 13:50:46 -0700
committerStan Hu <stanhu@gmail.com>2019-06-18 13:59:18 -0700
commit1b0c71ef8423cf20532953e58735dd7f61325e85 (patch)
tree9369ae15142a8d4700010ea1b6694122d0e73dc2 /spec/lib/feature_spec.rb
parent2dea03bf103a05d98366d6a8e9e906e890147bdc (diff)
downloadgitlab-ce-1b0c71ef8423cf20532953e58735dd7f61325e85.tar.gz
Cache feature flag names in Redis for a minute
We saw on GitLab.com, the SQL query, `SELECT "features"."key" FROM "features"` peaked at 2300 times per second. We can quiet this down a bit by caching it in Redis for a minute. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/63435
Diffstat (limited to 'spec/lib/feature_spec.rb')
-rw-r--r--spec/lib/feature_spec.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/spec/lib/feature_spec.rb b/spec/lib/feature_spec.rb
index a7163048370..6f05914f915 100644
--- a/spec/lib/feature_spec.rb
+++ b/spec/lib/feature_spec.rb
@@ -31,7 +31,8 @@ describe Feature do
expect(described_class.persisted_names).to be_empty
end
- it 'caches the feature names when request store is active', :request_store do
+ it 'caches the feature names when request store is active',
+ :request_store, :use_clean_rails_memory_store_caching do
Feature::FlipperFeature.create!(key: 'foo')
expect(Feature::FlipperFeature)
@@ -39,6 +40,12 @@ describe Feature do
.once
.and_call_original
+ expect(Rails.cache)
+ .to receive(:fetch)
+ .once
+ .with('flipper:persisted_names', expires_in: 1.minute)
+ .and_call_original
+
2.times do
expect(described_class.persisted_names).to eq(%w[foo])
end