// Copyright Epic Games, Inc. All Rights Reserved. using System; using System.Collections.Generic; using System.Threading.Tasks; using StackExchange.Redis; namespace EpicGames.Redis { /// /// Represents a typed Redis list with a given key /// public record struct RedisList(IDatabaseAsync Database, RedisListKey Key); /// /// Extension methods for sets /// public static class RedisListExtensions { #region Conditions /// public static Condition ListIndexEqual(this RedisList target, long index, TElement value) => target.Key.ListIndexEqual(index, value); /// public static Condition ListIndexExists(this RedisList target, long index) => target.Key.ListIndexExists(index); /// public static Condition ListIndexNotEqual(this RedisList target, long index, TElement value) => target.Key.ListIndexNotEqual(index, value); /// public static Condition ListIndexNotExists(this RedisList target, long index) => target.Key.ListIndexNotExists(index); /// public static Condition ListLengthEqual(this RedisList target, long length) => target.Key.ListLengthEqual(length); /// public static Condition ListLengthGreaterThan(this RedisList target, long length) => target.Key.ListLengthGreaterThan(length); /// public static Condition ListLengthLessThan(this RedisList target, long length) => target.Key.ListLengthLessThan(length); #endregion #region ListGetByIndexAsync /// public static Task GetByIndexAsync(this RedisList target, long index, CommandFlags flags = CommandFlags.None) => target.Database.ListGetByIndexAsync(target.Key, index, flags); #endregion #region ListInsertAfterAsync /// public static Task InsertAfterAsync(this RedisList target, TElement pivot, TElement item, CommandFlags flags = CommandFlags.None) => target.Database.ListInsertAfterAsync(target.Key, pivot, item, flags); #endregion #region ListInsertBeforeAsync /// public static Task InsertBeforeAsync(this RedisList target, TElement pivot, TElement item, CommandFlags flags = CommandFlags.None) => target.Database.ListInsertBeforeAsync(target.Key, pivot, item, flags); #endregion #region ListLeftPopAsync /// public static Task LeftPopAsync(this RedisList target, CommandFlags flags = CommandFlags.None) => target.Database.ListLeftPopAsync(target.Key, flags); #endregion #region ListLeftPushAsync /// public static Task LeftPushAsync(this RedisList target, TElement item, When when = When.Always, CommandFlags flags = CommandFlags.None) => target.Database.ListLeftPushAsync(target.Key, item, when, flags); /// public static Task LeftPushAsync(this RedisList target, TElement[] values, When when = When.Always, CommandFlags flags = CommandFlags.None) => target.Database.ListLeftPushAsync(target.Key, values, when, flags); #endregion #region ListLengthAsync /// public static Task LengthAsync(this RedisList target) => target.Database.ListLengthAsync(target.Key); #endregion #region ListRangeAsync /// public static Task RangeAsync(this RedisList target, long start = 0, long stop = -1, CommandFlags flags = CommandFlags.None) => target.Database.ListRangeAsync(target.Key, start, stop, flags); #endregion #region ListRemoveAsync /// public static Task RemoveAsync(this RedisList target, TElement value, long count = 0L, CommandFlags flags = CommandFlags.None) => target.Database.ListRemoveAsync(target.Key, value, count, flags); #endregion #region ListRightPopAsync /// public static Task RightPopAsync(this RedisList target, CommandFlags flags = CommandFlags.None) => target.Database.ListRightPopAsync(target.Key, flags); #endregion #region ListRightPushAsync /// public static Task RightPushAsync(this RedisList target, TElement item, When when = When.Always, CommandFlags flags = CommandFlags.None) => target.Database.ListRightPushAsync(target.Key, item, when, flags); /// public static Task RightPushAsync(this RedisList target, IEnumerable values, When when = When.Always, CommandFlags flags = CommandFlags.None) => target.Database.ListRightPushAsync(target.Key, values, when, flags); #endregion #region ListSetByIndexAsync /// public static Task SetByIndexAsync(this RedisList target, long index, TElement value, CommandFlags flags = CommandFlags.None) => target.Database.ListSetByIndexAsync(target.Key, index, value, flags); #endregion #region ListTrimAsync /// public static Task TrimAsync(this RedisList target, long start, long stop, CommandFlags flags = CommandFlags.None) => target.Database.ListTrimAsync(target.Key, start, stop, flags); #endregion } }