public Method

MemCache.servers=(servers)

Set the servers that the requests will be distributed between. Entries can be either strings of the form "hostname:port" or "hostname:port:weight" or MemCache::Server objects.

Source Code

# File active_support/vendor/memcache-client-1.5.0/memcache.rb, line 183
def servers=(servers)
  # Create the server objects.
  @servers = servers.collect do |server|
    case server
    when String
      host, port, weight = server.split ':', 3
      port ||= DEFAULT_PORT
      weight ||= DEFAULT_WEIGHT
      Server.new self, host, port, weight
    when Server
      if server.memcache.multithread != @multithread then
        raise ArgumentError, "can't mix threaded and non-threaded servers"
      end
      server
    else
      raise TypeError, "cannot convert #{server.class} into MemCache::Server"
    end
  end

  # Create an array of server buckets for weight selection of servers.
  @buckets = []
  @servers.each do |server|
    server.weight.times { @buckets.push(server) }
  end
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.