繁体   English   中英

如何使用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有关。

无论如何,如果你正在寻找处理Redis的哈希值作为.NET词典与非商业的客户端,就像StackExchange.Redis ,我推荐你使用CachingFramework.Redis依赖StackExchange.Redis库。

RedisDictionary实现的代码。 (请参阅文档

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM