How could we using couchbase with binary document as value?

we have heard if we want to save binary data as value to couchbase, it encoded with base64, which expand 30% in size and consume encode decode time. it may not acceptable, any other solutions? eg. modify couchbase to support binary value? thanks
BTW, any description doc on codes?Edit

Hello

So nothing is base64 encoded on disk, Couchbase (couchstore to be exact) simply takes the data as its get it and compress them on disk using snappy. Couchstore allows deciding this on a per-item basis, but ep-engine turns it on for every item.

Couchstore handles all datatypes the same. Today, just before an item is sent to Couchstore, ep-engine will check if it is JSON and if so set a flag indicating that in the item’s metadata, but this does not affect how the item is stored.

This flag is checked later by the view indexer, when preparing to pass the document to a view’s map function. It is at this point the item, if it is not known to be valid JSON, is base64 encoded before being passed to that function. This only happens in memory inside the indexer.

About the compression, today (all current releases) compression and decompression happens when sending and retrieving items from storage. That is, items are all uncompressed in memory, and compressed on disk.

These are internals things of the product that could evolve between releases so we have not documented all the details.

Regards
Tug
@tgrall