Method: MatrixSdk::Util::TinycacheAdapter#fetch
- Defined in:
- lib/matrix_sdk/util/tinycache_adapter.rb
#fetch(key, expires_in: nil, cache_level: nil, **_opts) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/matrix_sdk/util/tinycache_adapter.rb', line 42 def fetch(key, expires_in: nil, cache_level: nil, **_opts) expires_in ||= config.dig(key, :expires) cache_level ||= client&.cache cache_level ||= :all cache_level = Tinycache::CACHE_LEVELS[cache_level] return read(key) if exist?(key) && !cache[key].expired? value = yield write(key, value, expires_in: expires_in, cache_level: cache_level) end |