Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-06-18 23:50:46 +0300
committerStan Hu <stanhu@gmail.com>2019-06-18 23:59:18 +0300
commit1b0c71ef8423cf20532953e58735dd7f61325e85 (patch)
tree9369ae15142a8d4700010ea1b6694122d0e73dc2 /lib
parent2dea03bf103a05d98366d6a8e9e906e890147bdc (diff)
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 'lib')
-rw-r--r--lib/feature.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/feature.rb b/lib/feature.rb
index 749c861d740..cc9c9d44005 100644
--- a/lib/feature.rb
+++ b/lib/feature.rb
@@ -30,7 +30,12 @@ class Feature
end
def persisted_names
- Gitlab::SafeRequestStore[:flipper_persisted_names] ||= FlipperFeature.feature_names
+ Gitlab::SafeRequestStore[:flipper_persisted_names] ||=
+ 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 }
+ end
end
def persisted?(feature)