Using Redis hash data structures in ServiceStack
If you're familiar with the hash data structure, then working with the Redis implementation won't surprise you. A hash in Redis is roughly analogous to a C# dictionary—a collection of key/value pairs.
If you're just serializing objects to be stored, it's easy enough to store them as Redis strings. Where the hash can be useful is that it can allow you to update a given property on an object without fetching and changing the whole object at once.
Getting ready
For this example, we'll model the idea of allowing a user to change certain properties of their profile. We'll provide a service that accepts requests to update a given property of the user's profile, and which updates only that property.
The service interface might look something like this:
curl -d "[email protected]"http://myserver/user/Kyle/Email
We'll provide a POST
including the new e-mail address to a route /user/Kyle/Email
and expect the service to update only the e-mail...