Skip to content

Commit

Permalink
redis= wants a string, redis object, or redis::namespace object
Browse files Browse the repository at this point in the history
  • Loading branch information
defunkt committed May 16, 2011
1 parent 43a42ac commit 24eab54
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/resque.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ module Resque
extend self

# Accepts:
# 1. A 'hostname:port' string
# 2. A 'hostname:port:db' string (to select the Redis db)
# 3. A 'hostname:port/namespace' string (to set the Redis namespace)
# 4. A redis URL string 'redis://host:port'
# 1. A 'hostname:port' String
# 2. A 'hostname:port:db' String (to select the Redis db)
# 3. A 'hostname:port/namespace' String (to set the Redis namespace)
# 4. A Redis URL String 'redis://host:port'
# 5. An instance of `Redis`, `Redis::Client`, `Redis::DistRedis`,
# or `Redis::Namespace`.
def redis=(server)
if server.respond_to? :split
case server
when String
if server =~ /redis\:\/\//
redis = Redis.connect(:url => server, :thread_safe => true)
else
Expand All @@ -43,8 +44,8 @@ def redis=(server)
namespace ||= :resque

@redis = Redis::Namespace.new(namespace, :redis => redis)
elsif server.respond_to? :namespace=
@redis = server
when Redis::Namespace
@redis = server
else
@redis = Redis::Namespace.new(:resque, :redis => server)
end
Expand Down

0 comments on commit 24eab54

Please sign in to comment.