使用 StackExchange.Redis 中的 REDIS 集命令

Using REDIS Sets command from StackExchange.Redis

我需要用到一些与set操作相关的redis命令。我正在使用 StackExchange.Redis 连接到我的 redis 服务器并执行所需的操作。具体我需要进行以下操作

我可以在 IDatabase 界面中看到 SetAdd,但我怎样才能获得 SDIFF 和 SINTER 命令?

对于命令 SDIFF、SUNION 或 SINTER,您应该使用方法 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

看看一些 tests