如何使用 redis 字典添加 IEnumerable< T > 集合数据?
How can I add IEnumerable< T > collection data using redis dictionary?
我试过关注
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 字典中:(
我用过
您的代码似乎与 StackExchange.Redis
无关。可能与ServiceStack.Redis
.
有关
无论如何,如果您希望使用非商业客户端(例如 StackExchange.Redis
)将 Redis 哈希作为 .NET 字典来处理,我建议您使用依赖于 [=] 的 CachingFramework.Redis 库22=].
Here is the code for the RedisDictionary
implementation. (see the documentation)
我试过关注
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 字典中:( 我用过
您的代码似乎与 StackExchange.Redis
无关。可能与ServiceStack.Redis
.
无论如何,如果您希望使用非商业客户端(例如 StackExchange.Redis
)将 Redis 哈希作为 .NET 字典来处理,我建议您使用依赖于 [=] 的 CachingFramework.Redis 库22=].
Here is the code for the RedisDictionary
implementation. (see the documentation)