public async Task Push() { var list = new RedisList <int>(GlobalSettings.Default, "listkey1"); await list.Delete(); (await list.LeftPush(1)).Is(1); (await list.LeftPush(10)).Is(2); (await list.LeftPush(new[] { 100, 1000, 10000 }, TimeSpan.FromMilliseconds(1000))).Is(5); (await list.Range()).Is(10000, 1000, 100, 10, 1); await Task.Delay(TimeSpan.FromMilliseconds(1500)); (await list.Exists()).IsFalse(); (await list.RightPush(1)).Is(1); (await list.RightPush(10)).Is(2); (await list.RightPush(new[] { 100, 1000, 10000 }, TimeSpan.FromMilliseconds(1000))).Is(5); (await list.Range()).Is(1, 10, 100, 1000, 10000); await Task.Delay(TimeSpan.FromMilliseconds(1500)); (await list.Exists()).IsFalse(); }
public async Task Push() { var list = new RedisList<int>(GlobalSettings.Default, "listkey1"); await list.Delete(); (await list.LeftPush(1)).Is(1); (await list.LeftPush(10)).Is(2); (await list.LeftPush(new[] { 100, 1000, 10000 }, TimeSpan.FromMilliseconds(1000))).Is(5); (await list.Range()).Is(10000, 1000, 100, 10, 1); await Task.Delay(TimeSpan.FromMilliseconds(1500)); (await list.Exists()).IsFalse(); (await list.RightPush(1)).Is(1); (await list.RightPush(10)).Is(2); (await list.RightPush(new[] { 100, 1000, 10000 }, TimeSpan.FromMilliseconds(1000))).Is(5); (await list.Range()).Is(1, 10, 100, 1000, 10000); await Task.Delay(TimeSpan.FromMilliseconds(1500)); (await list.Exists()).IsFalse(); }
public async Task LeftPushAndFixLength() { var list = new RedisList<int>(GlobalSettings.Default, "listkey3"); await list.Delete(); await list.LeftPush(new[] { 1, 2, 3, 4, 5 }); await list.LeftPush(new[] { 6, 7, 8, 9, 10 }); (await list.Range()).Is(10, 9, 8, 7, 6, 5, 4, 3, 2, 1); await list.LeftPushAndFixLength(100, 10); (await list.Range()).Is(100, 10, 9, 8, 7, 6, 5, 4, 3, 2); await list.LeftPushAndFixLength(1000, 3); (await list.Range()).Is(1000, 100, 10); }
public async Task LeftPushAndFixLength() { var list = new RedisList <int>(GlobalSettings.Default, "listkey3"); await list.Delete(); await list.LeftPush(new[] { 1, 2, 3, 4, 5 }); await list.LeftPush(new[] { 6, 7, 8, 9, 10 }); (await list.Range()).Is(10, 9, 8, 7, 6, 5, 4, 3, 2, 1); await list.LeftPushAndFixLength(100, 10); (await list.Range()).Is(100, 10, 9, 8, 7, 6, 5, 4, 3, 2); await list.LeftPushAndFixLength(1000, 3); (await list.Range()).Is(1000, 100, 10); }
public static async Task <long> AddListAsync <T>(string key, T value) { try { var redis = new RedisList <T>(redisGroupBasic, key); var result = await redis.LeftPush(value); return(result); } catch (Exception ex) { Console.WriteLine(ex.Message); return(0); } }