Module: Slk::Services::MetaCache
- Defined in:
- lib/slk/services/meta_cache.rb
Overview
Read-through wrapper around CacheStore#get_meta/#set_meta with optional TTL and refresh override. Used by ProfileResolver and similar services.
Class Method Summary collapse
- .fetch(cache_store, workspace_name, key, ttl: nil, refresh: false) ⇒ Object
- .read(cache_store, workspace_name, key, ttl: nil) ⇒ Object
- .write(cache_store, workspace_name, key, value) ⇒ Object
Class Method Details
.fetch(cache_store, workspace_name, key, ttl: nil, refresh: false) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/slk/services/meta_cache.rb', line 10 def fetch(cache_store, workspace_name, key, ttl: nil, refresh: false) cached = read(cache_store, workspace_name, key, ttl: ttl) unless refresh return cached if cached value = yield write(cache_store, workspace_name, key, value) value end |
.read(cache_store, workspace_name, key, ttl: nil) ⇒ Object
19 20 21 22 23 |
# File 'lib/slk/services/meta_cache.rb', line 19 def read(cache_store, workspace_name, key, ttl: nil) return nil unless cache_store && workspace_name cache_store.(workspace_name, key, ttl: ttl) end |
.write(cache_store, workspace_name, key, value) ⇒ Object
25 26 27 28 29 |
# File 'lib/slk/services/meta_cache.rb', line 25 def write(cache_store, workspace_name, key, value) return unless cache_store && workspace_name && value cache_store.(workspace_name, key, value) end |