簡體   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