Joshua Fox
Joshua Fox

Reputation: 19665

How do I store byte arrays inside an object in Couchbase?

I want to store byte arrays (less than 1 MB) as a field value. I know about ByteArrayDocument and storing binary data as an independent non-JSON object.

To store a field as a byte array, do I just use com.couchbase.client.core.utils.Base64 to build a string value?

Or is some other approach recommended?

Upvotes: 2

Views: 522

Answers (1)

deniswsrosa
deniswsrosa

Reputation: 2460

If you want to store it as an attribute in your JSon document, base64 would be the right approach.

However, unless your document contains only metadata about the file itself, I don't recommend using this strategy. Documents are automatically cached, and if your document is big, the cache memory will be filled quite easily.

Upvotes: 1

Related Questions