RCBC-46 Adding Couchbase::ConnectionPool

Primarily to facilitate an option for ActiveSupport::Cache::CouchbaseStore
to use a connection pool in place of monitor locks for thread safety.
Thread safe locks are still the default and have been moved into their
own module.

Change-Id: I0e844b39f9b26bb5845b82a9050381d54f030dbb
Reviewed-on: http://review.couchbase.org/26028
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Implement Transcoders

Transcoder could be any entity which responds to #load and #dump

For example, this is how simple data transcoder, which use Zlib to
compress documents, will look like:

  class ZlibTranscoder
    FMT_ZLIB = 0x04

    def initialize(base)
      @base = base
    end

    def dump(obj, flags, options = {})
      obj, flags = @base.dump(obj, flags, options)
      z = Zlib::Deflate.new(Zlib::BEST_SPEED)
      buffer = z.deflate(obj, Zlib::FINISH)
      z.close
      [buffer, flags|FMT_ZLIB]
    end

    def load(blob, flags, options = {})
      # decompress value only if Zlib flag set
      if (flags & FMT_ZLIB) == FMT_ZLIB
        z = Zlib::Inflate.new
        blob = z.inflate(blob)
        z.finish
        z.close
      end
      @base.load(blob, flags, options)
    end
  end

Change-Id: I0e983c996e28e396132b30a8659ad4fbba44ba3d
Reviewed-on: http://review.couchbase.org/25933
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>