Behrooz
Behrooz

Reputation: 2533

Store Collection of Object in Redis

I want store collection of complex c# class in Redis This collection has 2 type of usage:

Dose exist any better solution for cache data for c#?

Upvotes: 2

Views: 2731

Answers (1)

Ofir Luzon
Ofir Luzon

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

Related Questions