Neo
Neo

Reputation: 16239

How can I add IEnumerable< T > collection data using redis dictionary?

I tried like following

var Settings = new RedisSettings("localhost");
public async void SetData< T >(IEnumerable< T > collection, string Key)
{
    RedisDictionary< object, T > mydictionary = new RedisDictionary< object, T >(Settings, typeof(T).Name);
    //how to add collection data into dictionary
    // i tried like following but failed 
    await mydictionary.Set(new[] { new KeyValuePair< object, IEnumerable< T > >(Key, collection) });

but it is not able to insert value into redis dictionary :( I have used

Upvotes: 1

Views: 1062

Answers (1)

thepirat000
thepirat000

Reputation: 13124

Your code does not seems to be related to StackExchange.Redis. It's probably related to ServiceStack.Redis.

Anyway if you're looking for handling Redis Hashes as .NET dictionaries with a non-commercial client, like StackExchange.Redis, I recommend you to use the CachingFramework.Redis library that relies on StackExchange.Redis.

Here is the code for the RedisDictionary implementation. (see the documentation)

Upvotes: 2

Related Questions