Reputation: 2533
I want store collection of complex c# class in Redis This collection has 2 type of usage:
second is retrieve specific item from collection by id
Dose exist any better solution for cache data for c#?
Upvotes: 2
Views: 2731
Reputation: 10947
You can use Redis Hashes for your C# objects. Populate it with HMSET:
HMSET objects:classname:id member1type member1value [member2type member2value]...
To get all objects, simply use HGETALL, and to get a specific member, HGET (you can also use HMGET to get more than one member).
Depands on your needs, you can also add sets with ids for each class, and than use SORT to get a specific member(s) from all stored class objects.
Upvotes: 2