class CacheService

Public Class Methods

cache() click to toggle source
# File lib/services/cache_service.rb, line 5
def cache
  @@cache
end
cache=(other_cache) click to toggle source
# File lib/services/cache_service.rb, line 9
def cache=(other_cache)
  @@cache = other_cache
end
delete(key, options = {}) click to toggle source
# File lib/services/cache_service.rb, line 34
def delete(key, options = {})
  return nil unless cache
  cache.delete(key, options)
end
initialize() click to toggle source
# File lib/services/cache_service.rb, line 13
def initialize
  config = ConfigService.load_config('cache_config.yml')[ConfigService.environment]
  # Load all the existing caches in the system, outside of the gem
  Dir.glob("#{File.expand_path('.')}/caches/*.rb").each { |rb_file| require rb_file }
  @@cache ||= eval(config['cache'])
  SdkLogger.logger = eval(config['logger']) if config['logger'].present?
rescue Exception => error
  puts("Error #{error.message}")
  @@cache = nil
end
read(key, options = {}) click to toggle source
# File lib/services/cache_service.rb, line 24
def read(key, options = {})
  return nil unless cache
  cache.read(key, options)
end
write(key, value, options = {}) click to toggle source
# File lib/services/cache_service.rb, line 29
def write(key, value, options = {})
  return nil unless cache
  cache.write(key, value, options)
end