Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving a collection of objects with BookSleeve

Tags:

booksleeve

I am new to both Redis and BookSleeve. I am evaluating whether I should use BookSleeve or ServiceStack.Redis.

ServiceStack seems much more staightforward but I like the idea of pipelining provided by BookSleeve.

I have Redis and BookSleeve running and getting and setting strings is a snap but I'm struggling to find examples of setting and getting a collection of objects such as my pocos.

public class MyType
{
....
}

IEnumerable<MyType> types = ....

How do I get and set these using BookSleeve?

Thanks.

like image 821
ChrisS Avatar asked Jan 26 '13 22:01

ChrisS


1 Answers

BookSleeve exposes APIs to read/write strings and blobs (byte[]), but it does not force you down any particular serialization route, or dictate whether a collection should be stored as a single value, vs a list, etc.

Basically, with BookSleeve you would serialize separately, via any serializer that you fancy (XML, json, protobuf, whatever), and send that. This is usually only about 2 or 3 lines of code (often involving MemoryStream).

like image 155
Marc Gravell Avatar answered Jan 03 '23 18:01

Marc Gravell