|
|
@ -418,10 +418,119 @@ namespace RedisStudyTest
|
|
|
|
Assert.Empty(mumbers);
|
|
|
|
Assert.Empty(mumbers);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 排它性参数Exclude设置 测试
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void SortedSetRangeByValue_Exclude_Test()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
SortedSetEntry[] sortedSetEntries = new SortedSetEntry[]
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
new SortedSetEntry("first",0),
|
|
|
|
|
|
|
|
new SortedSetEntry("second",0),
|
|
|
|
|
|
|
|
new SortedSetEntry("third",0),
|
|
|
|
|
|
|
|
new SortedSetEntry("four",0),
|
|
|
|
|
|
|
|
new SortedSetEntry("five",0),
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
redisSortedSetStudy.SortedSetAdd(defaultRedisKey, sortedSetEntries);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//默认:Exclude.None [Start,Stop]
|
|
|
|
|
|
|
|
var members = redisSortedSetStudy.SortedSetRangeByValue(defaultRedisKey, "first", "second", Exclude.None);
|
|
|
|
|
|
|
|
//firt five four second
|
|
|
|
|
|
|
|
Assert.Equal(4, members.Length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Exclude.Start (Start,Stop]
|
|
|
|
|
|
|
|
members = redisSortedSetStudy.SortedSetRangeByValue(defaultRedisKey, "first", "second", Exclude.Start);
|
|
|
|
|
|
|
|
//five four second
|
|
|
|
|
|
|
|
Assert.Equal(3, members.Length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Exclude.Stop [Start,Stop)
|
|
|
|
|
|
|
|
members = redisSortedSetStudy.SortedSetRangeByValue(defaultRedisKey, "first", "four", Exclude.Stop);
|
|
|
|
|
|
|
|
Assert.Equal(2, members.Length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Exclude.Both (Start,Stop)
|
|
|
|
|
|
|
|
members = redisSortedSetStudy.SortedSetRangeByValue(defaultRedisKey, "first", "four", Exclude.Both);
|
|
|
|
|
|
|
|
Assert.Single(members);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 分数相同,字典排序,逐字符比较(汉字的比较等待确认)
|
|
|
|
|
|
|
|
/// 字典顺序(”0”<…<”9”<”A”<…<”Z”<”a”<…<”z”)
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|
public void SortedSetRangeByValueTest()
|
|
|
|
public void SortedSetRangeByValueTest()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
SortedSetEntry[] sortedSetEntries = new SortedSetEntry[]
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
new SortedSetEntry("Andy",0),
|
|
|
|
|
|
|
|
new SortedSetEntry("and",0),
|
|
|
|
|
|
|
|
new SortedSetEntry("And",0),
|
|
|
|
|
|
|
|
new SortedSetEntry("Banana",0),
|
|
|
|
|
|
|
|
new SortedSetEntry("color",0),
|
|
|
|
|
|
|
|
new SortedSetEntry("query",0),
|
|
|
|
|
|
|
|
new SortedSetEntry("remove",0),
|
|
|
|
|
|
|
|
new SortedSetEntry("101",0),
|
|
|
|
|
|
|
|
new SortedSetEntry("304",0),
|
|
|
|
|
|
|
|
new SortedSetEntry("404",0),
|
|
|
|
|
|
|
|
new SortedSetEntry("王高峰",0),
|
|
|
|
|
|
|
|
new SortedSetEntry("刘山东",0),
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
redisSortedSetStudy.SortedSetAdd(defaultRedisKey, sortedSetEntries);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//数字排序
|
|
|
|
|
|
|
|
var members = redisSortedSetStudy.SortedSetRangeByValue(defaultRedisKey, "0", "5");
|
|
|
|
|
|
|
|
Assert.Contains("101", members);
|
|
|
|
|
|
|
|
Assert.Contains("304", members);
|
|
|
|
|
|
|
|
Assert.Contains("404", members);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
members = redisSortedSetStudy.SortedSetRangeByValue(defaultRedisKey, "10", "4");
|
|
|
|
|
|
|
|
Assert.Contains("101", members);
|
|
|
|
|
|
|
|
Assert.Contains("304", members);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
members = redisSortedSetStudy.SortedSetRangeByValue(defaultRedisKey, "11", "40");
|
|
|
|
|
|
|
|
Assert.Contains("304", members);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//字母排序
|
|
|
|
|
|
|
|
members = redisSortedSetStudy.SortedSetRangeByValue(defaultRedisKey, "And", "color");
|
|
|
|
|
|
|
|
//And Andy Banana and color
|
|
|
|
|
|
|
|
Assert.Contains("And", members);
|
|
|
|
|
|
|
|
Assert.Contains("Andy", members);
|
|
|
|
|
|
|
|
Assert.Contains("Banana", members);
|
|
|
|
|
|
|
|
Assert.Contains("and", members);
|
|
|
|
|
|
|
|
Assert.Contains("color", members);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
members = redisSortedSetStudy.SortedSetRangeByValue(defaultRedisKey, "A", "color");
|
|
|
|
|
|
|
|
//And Andy Banana and color
|
|
|
|
|
|
|
|
Assert.Contains("And", members);
|
|
|
|
|
|
|
|
Assert.Contains("Andy", members);
|
|
|
|
|
|
|
|
Assert.Contains("Banana", members);
|
|
|
|
|
|
|
|
Assert.Contains("and", members);
|
|
|
|
|
|
|
|
Assert.Contains("color", members);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
members = redisSortedSetStudy.SortedSetRangeByValue(defaultRedisKey, "A", "B");
|
|
|
|
|
|
|
|
//And Andy 不包括Banana,因为Ba排在B后
|
|
|
|
|
|
|
|
Assert.Contains("And", members);
|
|
|
|
|
|
|
|
Assert.Contains("Andy", members);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
members = redisSortedSetStudy.SortedSetRangeByValue(defaultRedisKey, "A", "Bb");
|
|
|
|
|
|
|
|
//And Andy Banana
|
|
|
|
|
|
|
|
Assert.Contains("And", members);
|
|
|
|
|
|
|
|
Assert.Contains("Andy", members);
|
|
|
|
|
|
|
|
Assert.Contains("Banana", members);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO:汉字排序规则不清楚
|
|
|
|
|
|
|
|
members = redisSortedSetStudy.SortedSetRangeByValue(defaultRedisKey, "王", "赵");
|
|
|
|
|
|
|
|
//王高峰
|
|
|
|
|
|
|
|
Assert.Contains("王高峰", members);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region SortedSetRangeByScore
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void SortedSetRangeByScore_NotKey_Test()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
redisSortedSetStudy.SortedSetRangeByScore(defaultRedisKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|