def initialize(*args)
servers = []
opts = {}
case args.length
when 0 then
when 1 then
arg = args.shift
case arg
when Hash then opts = arg
when Array then servers = arg
when String then servers = [arg]
else raise ArgumentError, 'first argument must be Array, Hash or String'
end
when 2 then
servers, opts = args
else
raise ArgumentError, "wrong number of arguments (#{args.length} for 2)"
end
opts = DEFAULT_OPTIONS.merge opts
@namespace = opts[:namespace]
@readonly = opts[:readonly]
@multithread = opts[:multithread]
@timeout = opts[:timeout]
@failover = opts[:failover]
@logger = opts[:logger]
@no_reply = opts[:no_reply]
@mutex = Mutex.new if @multithread
logger.info { "memcache-client #{VERSION} #{Array(servers).inspect}" } if logger
Thread.current[:memcache_client] = self.object_id if !@multithread
self.servers = servers
end