Hi everyone,
I’ve just started using Couchbase server with its .NET SDK. The data type I’m storing is a POCO C# class with a list inside, one document can be quite large, it can be hundreds of kilobytes if serialized to Json.
I’m only using Couchbase as a key-value store, I don’t care about the internal structure of the documents on the server. So I would prefer to store them compressed, that can save a lot in storage space (I tried one of my actual documents, if serialized to Json, it takes 237 KBytes, after zipping it was 10 KBytes). I would like to have compression already on the client side, so that I save not just on storage and memory on the server, but also on the network communication.
What is the idiomatic, simplest way to achieve this with the .NET SDK?
My code inserting documents is very simple.
bucket.Insert(
new Document<MyCustomPoco>
{
Content = item,
Id = key,
Expiry = expiry
}));
In the configuration I only specify connection information, I haven’t customized the serialization in any way.
In this blog post I read that by default we are using Json.NET for seralization, so I was expecting to see the inserted document on the server as Json. However, if I look at the inserted document with the management console, I see that it is in a binary format:
What is the reason for this? Is the SDK using a binary serializer by default? Or the document is getting compressed? If it’s the latter, does it get compressed already on the client side?
Maybe I’m missing something, but I couldn’t find any clear, official information about this. I’m looking for the approach which is the most idiomatic, and requires the least amount of custom coding.
Thanks for any suggestions!