module UmbrellioUtils::Store
Public Instance Methods
[](key)
click to toggle source
# File lib/umbrellio_utils/store.rb, line 15 def [](key) find(key)&.value end
[]=(key, value)
click to toggle source
# File lib/umbrellio_utils/store.rb, line 9 def []=(key, value) attrs = { key: key.to_s, value: JSON.dump(value), updated_at: Time.current } entry.upsert_dataset.insert(attrs) clear_cache_for(key) end
delete(key)
click to toggle source
# File lib/umbrellio_utils/store.rb, line 19 def delete(key) result = !!find(key)&.delete clear_cache_for(key) if result result end
entry()
click to toggle source
# File lib/umbrellio_utils/store.rb, line 29 def entry Sequel::Model(UmbrellioUtils.config.store_table_name) end
find(key)
click to toggle source
# File lib/umbrellio_utils/store.rb, line 25 def find(key) Rails.cache.fetch(cache_key_for(key)) { entry[key.to_s] } end
Private Instance Methods
cache_key_for(key)
click to toggle source
# File lib/umbrellio_utils/store.rb, line 35 def cache_key_for(key) "store-entry-#{key}" end
clear_cache_for(key)
click to toggle source
# File lib/umbrellio_utils/store.rb, line 39 def clear_cache_for(key) Rails.cache.delete(cache_key_for(key)) end