21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/redis_cacheable/connectable.rb', line 21
def redis(&blk)
raise ArgumentError.new("Need block") unless blk
unless Connectable.redis_connection
config = RedisCacheable::Configuration.config
Connectable.redis_connection = ConnectionPool.new(size: config.pool_size, timeout: config.timeout) {
Redis.new(host: config.host, port: config.port, driver: config.driver.to_sym)
}
end
Connectable.redis_connection.with do |conn|
namespaced_redis = Redis::Namespace.new(redis_namespace, redis: conn)
blk.call(namespaced_redis)
end
end
|