What serialization format should we use to store serialized objects in a SQL Server database

We are developing an individual caching solution that will use the SQL Server database to store cached objects. There is no cache in the application hosting environment, such as memcached or application fabric, so we must use the SQL Server database.

While most cached objects will be simple types (int, string, date, etc.), we will also need to store more complex types such as DataSets, DataTables, general collections, and custom classes.

I have very little experience with native .NET serialization and deserialization, but I believe that we will have to serialize the objects in some form (binary, xml, JSON, etc.) in order to store it in the database and then deserialize him when we pull him out of the database. I would like to get some expert opinions on what โ€œsome formโ€ should be.

We use JSON.NET to serialize data into JSON for various AJAX requests. My initial thought was to serialize cached data in JSON in order to store it in the database. However, I wanted to get a few opinions on what would be best for performance and data integrity.

+5
source share
3 answers

, (, json XML), . , . , :

  • , , Sql Server Management Studio . - , .

  • , , , , json, XML . , .

  • , , json XML. , , , .

  • , .net BCL , .

, , : , , / .

json , JSON.Net, . SSMS, json , XML.

+8

, . , Binary Serialization . , , . , , (, XML XSLT)

+3

, , .

protobuf-net , SO, , . , .

We use it for the same reason (for cache), after we tried other serialization libraries, it was faster and less as a result. Now in the cache scheme, you actually do not need to see with your own eyes what is inside, because it is not a setting that you may need to change something, because you have not yet fixed this function.

If you like to see what is in the cache object, you can make a simple function that prints it.

+2
source

All Articles