示例#1
0
        public static async Task <T> DeleteListAsync <T>(string key, bool IsLeft)
        {
            try
            {
                var redis = new RedisList <T>(redisGroupBasic, key);

                if (IsLeft)
                {
                    var result = await redis.LeftPop();

                    return(result.Value);
                }
                else
                {
                    var result = await redis.RightPop();

                    return(result.Value);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(default(T));
            }
        }
        public async Task Pop()
        {
            var list = new RedisList <int>(GlobalSettings.Default, "listkey6");
            await list.Delete();

            await list.RightPush(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });

            (await list.LeftPop()).Value.Is(1);
            (await list.RightPop()).Value.Is(9);

            (await list.Range()).Is(2, 3, 4, 5, 6, 7, 8);
        }
        public async Task Pop()
        {
            var list = new RedisList<int>(GlobalSettings.Default, "listkey6");
            await list.Delete();

            await list.RightPush(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });

            (await list.LeftPop()).Value.Is(1);
            (await list.RightPop()).Value.Is(9);

            (await list.Range()).Is(2, 3, 4, 5, 6, 7, 8);
        }