summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2019-07-02 16:11:33 +0000
committerRémy Coutable <remy@rymai.me>2019-07-02 16:11:33 +0000
commitff75b6b2dbd1d12b6989e3f8ead6e6e26d0742aa (patch)
tree4f513f298ff34856a691c425234e0fd7a12d8f0f
parent5de53c55654dc2e37d4fe51321f2ae55cb24dff7 (diff)
parent385aa46046ec83e6837c106576699f76e65876a7 (diff)
downloadgitlab-ce-ff75b6b2dbd1d12b6989e3f8ead6e6e26d0742aa.tar.gz
Merge branch 'sh-cache-flipper-names-memory-cache' into 'master'
Cache Flipper persisted names directly to local memory storage See merge request gitlab-org/gitlab-ce!30265
-rw-r--r--changelogs/unreleased/sh-cache-flipper-names-memory-cache.yml5
-rw-r--r--lib/feature.rb4
-rw-r--r--spec/lib/feature_spec.rb2
3 files changed, 9 insertions, 2 deletions
diff --git a/changelogs/unreleased/sh-cache-flipper-names-memory-cache.yml b/changelogs/unreleased/sh-cache-flipper-names-memory-cache.yml
new file mode 100644
index 00000000000..00443e81244
--- /dev/null
+++ b/changelogs/unreleased/sh-cache-flipper-names-memory-cache.yml
@@ -0,0 +1,5 @@
+---
+title: Cache Flipper persisted names directly to local memory storage
+merge_request: 30265
+author:
+type: performance
diff --git a/lib/feature.rb b/lib/feature.rb
index cc9c9d44005..22420e95ea2 100644
--- a/lib/feature.rb
+++ b/lib/feature.rb
@@ -34,7 +34,9 @@ class Feature
begin
# We saw on GitLab.com, this database request was called 2300
# times/s. Let's cache it for a minute to avoid that load.
- Rails.cache.fetch('flipper:persisted_names', expires_in: 1.minute) { FlipperFeature.feature_names }
+ Gitlab::ThreadMemoryCache.cache_backend.fetch('flipper:persisted_names', expires_in: 1.minute) do
+ FlipperFeature.feature_names
+ end
end
end
diff --git a/spec/lib/feature_spec.rb b/spec/lib/feature_spec.rb
index 6f05914f915..403e0785d1b 100644
--- a/spec/lib/feature_spec.rb
+++ b/spec/lib/feature_spec.rb
@@ -40,7 +40,7 @@ describe Feature do
.once
.and_call_original
- expect(Rails.cache)
+ expect(Gitlab::ThreadMemoryCache.cache_backend)
.to receive(:fetch)
.once
.with('flipper:persisted_names', expires_in: 1.minute)