public async Task SortedSetAdd() { var set = new RedisSortedSet <string>(GlobalSettings.Default, "set"); await set.Delete(); (await set.Add("hogehoge", 10)).Is(true); (await set.Add("hogehoge", 100)).Is(false); // already added but updated (await set.Add("huga", 1)).Is(true); (await set.RangeByRank()).Is("huga", "hogehoge"); (await set.RangeByRank(order: Order.Descending)).Is("hogehoge", "huga"); }
public async Task SortedSetAddRange() { var set = new RedisSortedSet<string>(GlobalSettings.Default, "set"); await set.Delete(); (await set.Add(new[] { new KeyValuePair<string, double>("hogehoge", 10), new KeyValuePair<string, double>("huga", 100) })).Is(2); (await set.Add(new[] { new KeyValuePair<string, double>("huga", 100), new KeyValuePair<string, double>("hugahuga", 1000) })).Is(1); var tako = await set.RangeByRank(); (await set.RangeByRank()).Is("hogehoge", "huga", "hugahuga"); (await set.RangeByRank(order: Order.Descending)).Is("hugahuga", "huga", "hogehoge"); }
public async Task SortedSetAdd() { var set = new RedisSortedSet<string>(GlobalSettings.Default, "set"); await set.Delete(); (await set.Add("hogehoge", 10)).Is(true); (await set.Add("hogehoge", 100)).Is(false); // already added but updated (await set.Add("huga", 1)).Is(true); (await set.RangeByRank()).Is("huga", "hogehoge"); (await set.RangeByRank(order: Order.Descending)).Is("hogehoge", "huga"); }
public async Task SortedSetAddRange() { var set = new RedisSortedSet <string>(GlobalSettings.Default, "set"); await set.Delete(); (await set.Add(new[] { new KeyValuePair <string, double>("hogehoge", 10), new KeyValuePair <string, double>("huga", 100) })).Is(2); (await set.Add(new[] { new KeyValuePair <string, double>("huga", 100), new KeyValuePair <string, double>("hugahuga", 1000) })).Is(1); var tako = await set.RangeByRank(); (await set.RangeByRank()).Is("hogehoge", "huga", "hugahuga"); (await set.RangeByRank(order: Order.Descending)).Is("hugahuga", "huga", "hogehoge"); }
public async Task Remove() { var set = new RedisSortedSet <string>(GlobalSettings.Default, "set"); await set.Delete(); await set.Add("a", 10); await set.Add("b", 100); await set.Add("c", 1000); await set.Add("d", 10000); await set.Add("e", 100000); await set.Add("f", 1000000); var c = await set.Get("c"); c.Value.Is("c"); c.Rank.Is(2); c.Score.Is(1000); (await set.Remove("c")).IsTrue(); (await set.Remove("c")).IsFalse(); (await set.Get("c")).IsNull(); await set.Add("c", 1000); (await set.RemoveRangeByRank(2, 3)).Is(2); (await set.RangeByRank()).Is("a", "b", "e", "f"); await set.Delete(); await set.Add("a", 10); await set.Add("b", 100); await set.Add("c", 1000); await set.Add("d", 10000); await set.Add("e", 100000); await set.Add("f", 1000000); (await set.RemoveRangeByScore(100, 10000)).Is(3); (await set.RangeByRank()).Is("a", "e", "f"); }
public async Task Remove() { var set = new RedisSortedSet<string>(GlobalSettings.Default, "set"); await set.Delete(); await set.Add("a", 10); await set.Add("b", 100); await set.Add("c", 1000); await set.Add("d", 10000); await set.Add("e", 100000); await set.Add("f", 1000000); var c = await set.Get("c"); c.Value.Is("c"); c.Rank.Is(2); c.Score.Is(1000); (await set.Remove("c")).IsTrue(); (await set.Remove("c")).IsFalse(); (await set.Get("c")).IsNull(); await set.Add("c", 1000); (await set.RemoveRangeByRank(2, 3)).Is(2); (await set.RangeByRank()).Is("a", "b", "e", "f"); await set.Delete(); await set.Add("a", 10); await set.Add("b", 100); await set.Add("c", 1000); await set.Add("d", 10000); await set.Add("e", 100000); await set.Add("f", 1000000); (await set.RemoveRangeByScore(100, 10000)).Is(3); (await set.RangeByRank()).Is("a", "e", "f"); }