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"); }
/// <summary> /// 删除超时记录 /// </summary> /// <param name="time"></param> /// <returns></returns> public long RemoveByOvertime(DateTime time) { return(SortedSet.RemoveRangeByScore(0, time.ToTimestamp())); }
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"); }