Expire cached user IDs that can see the performance after 5 minutes

If we don't expire the cached user IDs, the list of IDs would become
outdated when a new member is added, or when a member ios removed from
the allowed group.

Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
Rémy Coutable 2017-07-17 13:28:51 +02:00
parent 8b31ecd3d9
commit 7cbdaef452
No known key found for this signature in database
GPG Key ID: 46DF07E5CD9E96AB
1 changed files with 3 additions and 2 deletions

View File

@ -2,7 +2,8 @@ module Gitlab
module PerformanceBar
include Gitlab::CurrentSettings
ALLOWED_USER_IDS_KEY = 'performance_bar_allowed_user_ids'.freeze
ALLOWED_USER_IDS_KEY = 'performance_bar_allowed_user_ids:v2'.freeze
EXPIRY_TIME = 5.minutes
def self.enabled?(user = nil)
return false unless user && allowed_group_id
@ -15,7 +16,7 @@ module Gitlab
end
def self.allowed_user_ids
Rails.cache.fetch(ALLOWED_USER_IDS_KEY) do
Rails.cache.fetch(ALLOWED_USER_IDS_KEY, expires_in: EXPIRY_TIME) do
group = Group.find_by_id(allowed_group_id)
if group