我需要使用一些与set操作相关的redis命令。我正在使用StackExchange.Redis连接到我的redis服务器并执行所需的操作。具体来说,我需要执行以下操作
我能够在IDatabase界面中看到SetAdd但是如何获得SDIFF和SINTER命令?
答案 0 :(得分:4)
您应该使用方法IDatabase.SetCombine()
执行命令SDIFF,SUNION或SINTER。
/// <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
可以是Union
,Intersect
或Difference
查看一些tests