簡體   English   中英

從StackExchange.Redis使用REDIS Sets命令

[英]Using REDIS Sets command from StackExchange.Redis

我需要使用一些與set操作相關的redis命令。 我正在使用StackExchange.Redis連接到我的Redis服務器並執行所需的操作。 具體來說,我需要執行以下操作

  • 將商品添加到集合(SADD)
  • 檢查兩組之間的差異(SDIFF)
  • 獲取2組之間的公共元素(SINTER)

我可以在IDatabase界面中看到SetAdd,但是如何獲取SDIFF和SINTER命令?

對於命令SDIFF,SUNION或SINTER,應使用IDatabase.SetCombine IDatabase.SetCombine()方法。

    /// <summary>
    /// Returns the members of the set resulting from the specified operation against the given sets.
    /// </summary>
    /// <returns>list with members of the resulting set.</returns>
    /// <remarks>http://redis.io/commands/sunion</remarks>
    /// <remarks>http://redis.io/commands/sinter</remarks>
    /// <remarks>http://redis.io/commands/sdiff</remarks>
    RedisValue[] SetCombine(SetOperation operation, RedisKey first, RedisKey second, CommandFlags flags = CommandFlags.None);

SetOperation可以是UnionIntersectDifference

看看一些測試

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM