Search code examples
booksleeve

Saving a collection of objects with 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.


Solution

  • When using ServiceStack.Redis it's just a matter of:

    var redisClient = new RedisClient();
    redisClient.StoreAll(myTypes);
    

    Not sure what pipelining features you're looking for but you can create custom pipelined operations with ServiceStack.Redis's transactions API (which are always pipelined) or if you don't want the operations to execute within a transaction you can use Redis.CreatePipeline() - see these tests for some examples.