|
|
|
@ -1106,6 +1106,142 @@ namespace RedisStudyTest
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region SortedSetRemoveRangeByScore
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void SortedSetRemoveRangeByScore_NotKey_Test()
|
|
|
|
|
{
|
|
|
|
|
var removeNumber = redisSortedSetStudy.SortedSetRemoveRangeByScore(defaultRedisKey,0,10000);
|
|
|
|
|
Assert.Equal(0, removeNumber);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void SortedSetRemoveRangeByScore_NotScore_Test()
|
|
|
|
|
{
|
|
|
|
|
SortedSetEntry[] sortedSetEntries = new SortedSetEntry[]
|
|
|
|
|
{
|
|
|
|
|
new SortedSetEntry("first",1),
|
|
|
|
|
new SortedSetEntry("second",2),
|
|
|
|
|
new SortedSetEntry("third",3),
|
|
|
|
|
new SortedSetEntry("five",4),
|
|
|
|
|
new SortedSetEntry("six",5),
|
|
|
|
|
new SortedSetEntry("seven",6),
|
|
|
|
|
};
|
|
|
|
|
redisSortedSetStudy.SortedSetAdd(defaultRedisKey, sortedSetEntries);
|
|
|
|
|
|
|
|
|
|
var removeNumber = redisSortedSetStudy.SortedSetRemoveRangeByScore(defaultRedisKey, 1000, 10000);
|
|
|
|
|
Assert.Equal(0, removeNumber);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void SortedSetRemoveRangeByScoreTest()
|
|
|
|
|
{
|
|
|
|
|
SortedSetEntry[] sortedSetEntries = new SortedSetEntry[]
|
|
|
|
|
{
|
|
|
|
|
new SortedSetEntry("first",1),
|
|
|
|
|
new SortedSetEntry("second",2),
|
|
|
|
|
new SortedSetEntry("third",3),
|
|
|
|
|
new SortedSetEntry("five",4),
|
|
|
|
|
new SortedSetEntry("six",5),
|
|
|
|
|
new SortedSetEntry("seven",6),
|
|
|
|
|
};
|
|
|
|
|
redisSortedSetStudy.SortedSetAdd(defaultRedisKey, sortedSetEntries);
|
|
|
|
|
|
|
|
|
|
var removeNumber = redisSortedSetStudy.SortedSetRemoveRangeByScore(defaultRedisKey, 1, 3);
|
|
|
|
|
Assert.Equal(3, removeNumber);
|
|
|
|
|
|
|
|
|
|
removeNumber = redisSortedSetStudy.SortedSetRemoveRangeByScore(defaultRedisKey, 4, 4);
|
|
|
|
|
Assert.Equal(1, removeNumber);
|
|
|
|
|
|
|
|
|
|
removeNumber = redisSortedSetStudy.SortedSetRemoveRangeByScore(defaultRedisKey, 5, 6);
|
|
|
|
|
Assert.Equal(2, removeNumber);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region SortedSetRemoveRangeByScore
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void SortedSetRemoveRangeByValue_NotKey_Test()
|
|
|
|
|
{
|
|
|
|
|
var removeNumber = redisSortedSetStudy.SortedSetRemoveRangeByValue(defaultRedisKey, "0", "zz");
|
|
|
|
|
Assert.Equal(0, removeNumber);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void SortedSetRemoveRangeByValue_NotValue_Test()
|
|
|
|
|
{
|
|
|
|
|
SortedSetEntry[] sortedSetEntries = new SortedSetEntry[]
|
|
|
|
|
{
|
|
|
|
|
new SortedSetEntry("first",1),
|
|
|
|
|
new SortedSetEntry("second",2),
|
|
|
|
|
new SortedSetEntry("third",3),
|
|
|
|
|
new SortedSetEntry("five",4),
|
|
|
|
|
new SortedSetEntry("six",5),
|
|
|
|
|
new SortedSetEntry("seven",6),
|
|
|
|
|
};
|
|
|
|
|
redisSortedSetStudy.SortedSetAdd(defaultRedisKey, sortedSetEntries);
|
|
|
|
|
|
|
|
|
|
var removeNumber = redisSortedSetStudy.SortedSetRemoveRangeByValue(defaultRedisKey, "w", "z");
|
|
|
|
|
Assert.Equal(0, removeNumber);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void SortedSetRemoveRangeByValueTest()
|
|
|
|
|
{
|
|
|
|
|
SortedSetEntry[] sortedSetEntries = new SortedSetEntry[]
|
|
|
|
|
{
|
|
|
|
|
new SortedSetEntry("first",0),
|
|
|
|
|
new SortedSetEntry("second",0),
|
|
|
|
|
new SortedSetEntry("third",0),
|
|
|
|
|
new SortedSetEntry("five",0),
|
|
|
|
|
new SortedSetEntry("six",0),
|
|
|
|
|
new SortedSetEntry("seven",0),
|
|
|
|
|
};
|
|
|
|
|
redisSortedSetStudy.SortedSetAdd(defaultRedisKey, sortedSetEntries);
|
|
|
|
|
|
|
|
|
|
var removeNumber = redisSortedSetStudy.SortedSetRemoveRangeByValue(defaultRedisKey, "first", "second");
|
|
|
|
|
Assert.Equal(3, removeNumber);
|
|
|
|
|
|
|
|
|
|
removeNumber = redisSortedSetStudy.SortedSetRemoveRangeByValue(defaultRedisKey, "seven", "seven");
|
|
|
|
|
Assert.Equal(1, removeNumber);
|
|
|
|
|
|
|
|
|
|
removeNumber = redisSortedSetStudy.SortedSetRemoveRangeByValue(defaultRedisKey, "six", "third");
|
|
|
|
|
Assert.Equal(2, removeNumber);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region SortedSetCombineAndStore todo:待做任务
|
|
|
|
|
[Fact]
|
|
|
|
|
public void SortedSetCombineAndStoreTest()
|
|
|
|
|
{
|
|
|
|
|
//redisSortedSetStudy.SortedSetCombineAndStore();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region SortedSetScan
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void SortedSetScanTest()
|
|
|
|
|
{
|
|
|
|
|
SortedSetEntry[] sortedSetEntries = new SortedSetEntry[]
|
|
|
|
|
{
|
|
|
|
|
new SortedSetEntry("first",1),
|
|
|
|
|
new SortedSetEntry("second",2),
|
|
|
|
|
new SortedSetEntry("third",3),
|
|
|
|
|
new SortedSetEntry("five",4),
|
|
|
|
|
new SortedSetEntry("six",5),
|
|
|
|
|
new SortedSetEntry("seven",6),
|
|
|
|
|
};
|
|
|
|
|
redisSortedSetStudy.SortedSetAdd(defaultRedisKey, sortedSetEntries);
|
|
|
|
|
|
|
|
|
|
var members = redisSortedSetStudy.SortedSetScan(defaultRedisKey,"*", 100,CommandFlags.None);
|
|
|
|
|
Assert.Equal(6, members.Count());
|
|
|
|
|
|
|
|
|
|
members = redisSortedSetStudy.SortedSetScan(defaultRedisKey);
|
|
|
|
|
Assert.Equal(6, members.Count());
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 清理
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|