Method: MemCache#initialize
- Defined in:
- lib/gems/activesupport-2.2.2/lib/active_support/vendor/memcache-client-1.5.1/memcache.rb
#initialize(*args) ⇒ MemCache
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.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/gems/activesupport-2.2.2/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 |