class Debounce::RedisConnection
Public Class Methods
create(options={})
click to toggle source
# File lib/debounce/redis_connection.rb, line 8 def create(options={}) url = options[:url] || determine_redis_provider if url options[:url] = url end build_client(options) end
Private Class Methods
build_client(options)
click to toggle source
# File lib/debounce/redis_connection.rb, line 19 def build_client(options) namespace = options[:namespace] client = Redis.new client_opts(options) if namespace require 'redis/namespace' Redis::Namespace.new(namespace, :redis => client) else client end end
client_opts(options)
click to toggle source
# File lib/debounce/redis_connection.rb, line 31 def client_opts(options) opts = options.dup if opts[:namespace] opts.delete(:namespace) end if opts[:network_timeout] opts[:timeout] = opts[:network_timeout] opts.delete(:network_timeout) end opts[:driver] = opts[:driver] || 'ruby' opts end
determine_redis_provider()
click to toggle source
# File lib/debounce/redis_connection.rb, line 47 def determine_redis_provider ENV[ENV['REDIS_PROVIDER'] || 'REDIS_URL'] end