class method self.new

Ruby on Rails 2.2.3

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

self.new(*args)

Accepts a list of servers and a list of opts. servers may be omitted. See servers= for acceptable server list arguments.

Valid options for opts are:

[:namespace]   Prepends this value to all keys added or retrieved.
[:readonly]    Raises an exception on cache writes when true.
[:multithread] Wraps cache access in a Mutex for thread safety.

Other options are ignored.

Parameters

args rest
Source
# File activesupport/lib/active_support/vendor/memcache-client-1.5.1/memcache.rb, line 127
  def initialize(*args)
    servers = []
    opts = {}

    case args.length
    when 0 then # NOP
    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]
    @mutex       = Mutex.new if @multithread
    @buckets     = []
    self.servers = servers
  end

Defined in activesupport/lib/active_support/vendor/memcache-client-1.5.1/memcache.rb line 127 · View on GitHub · Improve this page · Find usages on GitHub

Defined in MemCache

Type at least 2 characters to search.

↑↓ navigate · open · esc close