class Tng::Gtk::Utils::Cache

Constants

CACHE_PREFIX
LOGGER
LOG_COMPONENT
STRATEGIES

Attributes

strategy[RW]

Public Class Methods

cache(record) click to toggle source
# File lib/tng/gtk/utils/cache.rb, line 79
def self.cache(record)
  unless record.key?(:uuid)
    LOGGER.error(component: LOG_COMPONENT, operation:__method__.to_s, message:"key :uuid is missing in record #{record}") 
    return nil
  end
  self.strategy.set("#{CACHE_PREFIX}:#{record[:uuid]}", record.to_json)
  record
end
cached?(key) click to toggle source
# File lib/tng/gtk/utils/cache.rb, line 87
def self.cached?(key)
  data = self.strategy.get("#{CACHE_PREFIX}:#{key}")
  return '' if data.nil?
  JSON.parse(data, symbolize_names: :true) 
end
clear(key) click to toggle source
# File lib/tng/gtk/utils/cache.rb, line 92
def self.clear(key)
  self.strategy.del(key)
end