Book Image

ServiceStack 4 Cookbook

Book Image

ServiceStack 4 Cookbook

Overview of this book

Table of Contents (18 chapters)
ServiceStack 4 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Using typed data structures with ServiceStack and Redis


We learned about using Redis hash data structures in a previous recipe. In that explanation, as with others, we used the ServiceStack client to directly manipulate the Redis data structures on the server. If you want a higher level of abstraction, you can use the Redis client's typed approach. Instead of directly dealing with strings and other primitives, you can tell the Redis client the type you want to store and then let it handle some of the details. In this recipe, we'll make use of this approach.

Getting ready

If we continue with our social network theme, we can begin to model the concept of a comment. For our service, a comment is a reply on a status:

Kyle's status: Hey guys what movie should we see?

  • Darren's comment: How about Guardians of the Galaxy?

  • Kyle's comment: That works!

We saw in the previous recipe how we can store our statuses in a list. We could store our comments now in a hash. The hash key could be the StatusId of...