module RedisClient::Config::Common
def build_connection_prelude
def build_connection_prelude prelude = [] pass = password if protocol == 3 prelude << if pass ["HELLO", "3", "AUTH", username, pass] else ["HELLO", "3"] end elsif pass prelude << if @username && !@username.empty? ["AUTH", @username, pass] else ["AUTH", pass] end end if @db && @db != 0 prelude << ["SELECT", @db.to_s] end # Deep freeze all the strings and commands prelude.map! do |commands| commands = commands.map { |str| str.frozen? ? str : str.dup.freeze } commands.freeze end prelude.freeze end