C# 如何添加IEnumerable<;T>;使用redis字典收集数据?
我试着跟在后面C# 如何添加IEnumerable<;T>;使用redis字典收集数据?,c#,dictionary,redis,stackexchange.redis,cachingframework.redis,C#,Dictionary,Redis,Stackexchange.redis,Cachingframework.redis,我试着跟在后面 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
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) });
var Settings=new RedisSettings(“localhost”);
公共异步void SetData(IEnumerable集合,字符串键)
{
RedisDictionary
但它无法将值插入redis字典:(
我使用了您的代码似乎与
StackExchange.Redis
无关。它可能与ServiceStack.Redis
有关
无论如何,如果您希望使用非商业客户端(如StackExchange.Redis
)将Redis哈希作为.NET词典处理,我建议您使用依赖StackExchange.Redis的库
是
RedisDictionary
实现的代码。(参见)也许我疯了,但是RedisDictionary
aStackExchange.Redis
class?O\u O