2021-05-13 05:10:44 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Cache
|
|
|
|
class << self
|
|
|
|
# Utility method for performing a fetch but only
|
|
|
|
# once per request, storing the returned value in
|
|
|
|
# the request store, if active.
|
|
|
|
def fetch_once(key, **kwargs)
|
|
|
|
Gitlab::SafeRequestStore.fetch(key) do
|
|
|
|
Rails.cache.fetch(key, **kwargs) do
|
|
|
|
yield
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-06-07 20:10:34 -04:00
|
|
|
|
|
|
|
# Hook for EE
|
|
|
|
def delete(key)
|
|
|
|
Rails.cache.delete(key)
|
|
|
|
end
|
2021-05-13 05:10:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-06-07 20:10:34 -04:00
|
|
|
|
|
|
|
Gitlab::Cache.prepend_mod
|