1

我试过如下

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) });

但它无法将值插入redis字典:(我用过

4

1 回答 1

1

您的代码似乎与StackExchange.Redis. 很可能与ServiceStack.Redis.

无论如何,如果您正在寻找使用非商业客户端(如 .NET)将 Redis 哈希作为 .NET 字典处理StackExchange.Redis,我建议您使用依赖于StackExchange.Redis 的CachingFramework.Redis库。

RedisDictionary实现的代码。(见文档

于 2015-11-04T22:23:43.603 回答