Module: Gitlab::Cache

Defined in:
lib/gitlab/cache.rb,
lib/gitlab/cache/helpers.rb,
lib/gitlab/cache/request_cache.rb,
lib/gitlab/cache/import/caching.rb,
lib/gitlab/cache/ci/project_pipeline_status.rb

Defined Under Namespace

Modules: Ci, Helpers, Import, RequestCache

Class Method Summary collapse

Class Method Details

.delete(key) ⇒ Object

Hook for EE


18
19
20
# File 'lib/gitlab/cache.rb', line 18

def delete(key)
  Rails.cache.delete(key)
end

.fetch_once(key, **kwargs) ⇒ Object

Utility method for performing a fetch but only once per request, storing the returned value in the request store, if active.


9
10
11
12
13
14
15
# File 'lib/gitlab/cache.rb', line 9

def fetch_once(key, **kwargs)
  Gitlab::SafeRequestStore.fetch(key) do
    Rails.cache.fetch(key, **kwargs) do
      yield
    end
  end
end