public async Task DictionaryIncr() { var dict = new RedisDictionary <string, long>(GlobalSettings.Default, "dict"); await dict.Delete(); (await dict.Increment("hogehoge", 100)).Is(100); (await dict.Increment("hogehoge", 100)).Is(200); (await dict.Increment("hogehoge", -100)).Is(100); (await dict.Get("hogehoge")).Value.Is(100); (await dict.IncrementLimitByMax("hogehoge", 40, 150)).Is(140); (await dict.IncrementLimitByMax("hogehoge", 40, 150)).Is(150); (await dict.IncrementLimitByMin("hogehoge", -40, 100)).Is(110); (await dict.IncrementLimitByMin("hogehoge", -40, 100)).Is(100); var dict2 = new RedisDictionary <string, double>(GlobalSettings.Default, "dict2"); await dict2.Delete(); (await dict2.Increment("hogehoge", 100.5)).Is(100.5); (await dict2.Increment("hogehoge", 100.0)).Is(200.5); (await dict2.Increment("hogehoge", -100.0)).Is(100.5); (await dict2.Get("hogehoge")).Value.Is(100.5); (await dict2.IncrementLimitByMax("hogehoge", 40.1, 150.9)).Is(140.6); (await dict2.IncrementLimitByMax("hogehoge", 40.3, 150.9)).Is(150.9); (await dict2.IncrementLimitByMin("hogehoge", -40.1, 100.9)).Is(110.8); (await dict2.IncrementLimitByMin("hogehoge", -40.3, 100.9)).Is(100.9); }
public async Task DictionaryIncr() { var dict = new RedisDictionary<string, long>(GlobalSettings.Default, "dict"); await dict.Delete(); (await dict.Increment("hogehoge", 100)).Is(100); (await dict.Increment("hogehoge", 100)).Is(200); (await dict.Increment("hogehoge", -100)).Is(100); (await dict.Get("hogehoge")).Value.Is(100); (await dict.IncrementLimitByMax("hogehoge", 40, 150)).Is(140); (await dict.IncrementLimitByMax("hogehoge", 40, 150)).Is(150); (await dict.IncrementLimitByMin("hogehoge", -40, 100)).Is(110); (await dict.IncrementLimitByMin("hogehoge", -40, 100)).Is(100); var dict2 = new RedisDictionary<string, double>(GlobalSettings.Default, "dict2"); await dict2.Delete(); (await dict2.Increment("hogehoge", 100.5)).Is(100.5); (await dict2.Increment("hogehoge", 100.0)).Is(200.5); (await dict2.Increment("hogehoge", -100.0)).Is(100.5); (await dict2.Get("hogehoge")).Value.Is(100.5); (await dict2.IncrementLimitByMax("hogehoge", 40.1, 150.9)).Is(140.6); (await dict2.IncrementLimitByMax("hogehoge", 40.3, 150.9)).Is(150.9); (await dict2.IncrementLimitByMin("hogehoge", -40.1, 100.9)).Is(110.8); (await dict2.IncrementLimitByMin("hogehoge", -40.3, 100.9)).Is(100.9); }
public async Task DictDecrMin() { var v = new RedisDictionary <int>(settings, "test-hash"); await v.Set("a", 100); (await v.IncrementLimitByMin("a", -10, 0)).Is(90); (await v.IncrementLimitByMin("a", -20, 0)).Is(70); (await v.IncrementLimitByMin("a", -30, 0)).Is(40); (await v.IncrementLimitByMin("a", -42, 0)).Is(0); (await v.IncrementLimitByMin("a", -50, 0)).Is(0); (await v.Get("a")).Is(0); var v2 = new RedisDictionary <double>(settings, "test-hash"); await v2.Set("a", 100); (await v2.IncrementLimitByMin("a", -10.5, 0.5)).Is(89.5); (await v2.IncrementLimitByMin("a", -20.5, 0.5)).Is(69); (await v2.IncrementLimitByMin("a", -40.5, 0.5)).Is(28.5); (await v2.IncrementLimitByMin("a", -40.5, 0.5)).Is(0.5); (await v2.Get("a")).Is(0.5); }
public async Task DictDecrMin() { var v = new RedisDictionary<int>(settings, "test-hash"); await v.Set("a", 100); (await v.IncrementLimitByMin("a", -10, 0)).Is(90); (await v.IncrementLimitByMin("a", -20, 0)).Is(70); (await v.IncrementLimitByMin("a", -30, 0)).Is(40); (await v.IncrementLimitByMin("a", -42, 0)).Is(0); (await v.IncrementLimitByMin("a", -50, 0)).Is(0); (await v.Get("a")).Is(0); var v2 = new RedisDictionary<double>(settings, "test-hash"); await v2.Set("a", 100); (await v2.IncrementLimitByMin("a", -10.5, 0.5)).Is(89.5); (await v2.IncrementLimitByMin("a", -20.5, 0.5)).Is(69); (await v2.IncrementLimitByMin("a", -40.5, 0.5)).Is(28.5); (await v2.IncrementLimitByMin("a", -40.5, 0.5)).Is(0.5); (await v2.Get("a")).Is(0.5); }