Module: Garage::Strategy::AuthServer::Cache
- Defined in:
- lib/garage/strategy/auth_server.rb
Class Method Summary collapse
Class Method Details
.default_ttl ⇒ Object
40 41 42 |
# File 'lib/garage/strategy/auth_server.rb', line 40 def self.default_ttl Garage.configuration.ttl_for_access_token_cache end |
.with_cache(key) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/garage/strategy/auth_server.rb', line 29 def self.with_cache(key) return yield unless Garage.configuration.cache_acceess_token_validation? cached_token = Rails.cache.read(key) return cached_token if cached_token && !cached_token.expired? token = yield Rails.cache.write(key, token, expires_in: default_ttl) if token && token.accessible? token end |