I use ServiceStack and would like to store objects as hashes in Redis and get an access to their parts (fields) by ids without serializing whole object, so I have a questions:
Is there a way to use other property then "Id", to mark id field? I
am using naming conventions, where id field is named like "class
name+Id". So in User class there will be UserId id field, in
Itemclass ItemId and so on.
Is the a way to update properties that were changed in the object without serializing whole object into hash and without low-level manipulations with hash command of Redis? For example, by using some sort of lambdas.
User user=client.GetById(userId);
user.Name="New name";
client.Update<User>(user,u=>u.Name);
Yes you can override the default using ModelConfig with:
ModelConfig<User>.Id(x => x.UserId);
ModelConfig<Item>.Id(x => x.ItemId);
This needs to be configured once on startup before you use the RedisClient.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With