request_cache.rb 425 B

123456789101112131415161718
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Auth
  3. class RequestCache < ActiveSupport::CurrentAttributes
  4. attribute :request_cache
  5. def self.fetch_value(name)
  6. self.request_cache ||= {}
  7. return self.request_cache[name] if !self.request_cache[name].nil?
  8. self.request_cache[name] = yield
  9. end
  10. def self.clear
  11. self.request_cache = {}
  12. end
  13. end
  14. end