require 'memcached' class MemcacheAuth < Memcached def initialize(servers = nil, opts = {}) if !servers && ENV['MEMCACHE_SERVERS'] servers = ENV['MEMCACHE_SERVERS'].split(',') end super(servers, opts) end end class MemcacheAuth::Rails < Memcached::Rails def initialize(*args) opts = args.last.is_a?(Hash) ? args.pop : {} servers = Array( args.any? ? args.unshift : opts.delete(:servers) ).flatten.compact if servers.empty? && ENV['MEMCACHE_SERVERS'] servers = ENV['MEMCACHE_SERVERS'].split(',') end super(servers, opts) end end