class Cachext::Configuration
Constants
- MissingConfiguration
Attributes
breaker_timeout[RW]
cache[RW]
debug[RW]
default_errors[RW]
default_expires_in[RW]
error_logger[RW]
failure_threshold[RW]
heartbeat_expires[RW]
max_lock_wait[RW]
not_found_errors[RW]
raise_errors[RW]
redis[RW]
Public Class Methods
new()
click to toggle source
# File lib/cachext/configuration.rb, line 39 def initialize self.raise_errors = false self.default_errors = [ Faraday::Error::ConnectionFailed, Faraday::Error::TimeoutError, ] self.not_found_errors = [ Faraday::Error::ResourceNotFound, ] self.default_expires_in = 60 self.max_lock_wait = 5 self.debug = ENV['CACHEXT_DEBUG'] == "true" self.heartbeat_expires = 2 self.failure_threshold = 3 self.breaker_timeout = 60 @debug_mutex = Mutex.new end
setup() { |config| ... }
click to toggle source
# File lib/cachext/configuration.rb, line 22 def self.setup config = new yield config if config.cache.nil? raise MissingConfiguration, "Must configure the config.cache. Try config.cache = Rails.cache" end if config.redis.nil? raise MissingConfiguration, "Must configure the config.redis. Try config.redis = Redis.current" end config.lock_manager config end
Public Instance Methods
lock_manager()
click to toggle source
# File lib/cachext/configuration.rb, line 57 def lock_manager @lock_manager ||= Redlock::Client.new [lock_redis], retry_count: 1 end
lock_redis()
click to toggle source
# File lib/cachext/configuration.rb, line 61 def lock_redis redis end
log_errors?()
click to toggle source
# File lib/cachext/configuration.rb, line 65 def log_errors? error_logger.present? end