class Aranea::Failure::Repository

TODO: Actually implement Repository pattern, dependency injection and all. As is we only support sharing between multiple instances if Rails.cache exists and does

Constants

KEY

Public Class Methods

cache() click to toggle source
# File lib/aranea/failure_repository.rb, line 78
def cache
  @cache ||= rails_cache || memory_store
end
clear() click to toggle source
# File lib/aranea/failure_repository.rb, line 74
def clear
  cache.delete(KEY)
end
get() click to toggle source
# File lib/aranea/failure_repository.rb, line 70
def get
  cache.read(KEY)
end
memory_store() click to toggle source
# File lib/aranea/failure_repository.rb, line 86
def memory_store
  require "active_support/cache"
  ActiveSupport::Cache::MemoryStore.new
end
rails_cache() click to toggle source
# File lib/aranea/failure_repository.rb, line 82
def rails_cache
  defined?(Rails.cache) && Rails.cache
end
store(failure, lifespan) click to toggle source
# File lib/aranea/failure_repository.rb, line 65
def store(failure, lifespan)
  failure.expiration_date = Time.now + lifespan
  cache.write(KEY, failure, expires_in: lifespan)
end