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 the ServiceStack.Redis client to access a Redis list


We've seen already that Redis can act as a key-value store, allowing us to temporarily store objects at a specific location from where we can retrieve them later. Redis also has other data structures it can store, including a list structure. Redis implements the list as a linked list. Accessing linked lists randomly is less efficient; however, they have excellent performance characteristics to add elements to the beginning or the end of the list, as well as fetch elements at the beginning or end of the list.

Getting ready

Let's try to use the Redis list to implement a status timeline suitable for a social network. We'll build a basic service that can accept new statuses and retrieve the last n statuses from the timeline. We'll create a service layer that handles the details of dealing with the client and an access layer that handles the specifics of dealing with the Redis list.

How to do it…

  1. First, let's build a basic service that can...