/// <summary> /// SORT : https://redis.io/commands/sort /// </summary> public Task <long> SortAndStoreAsync(RedisSet <T> destination, long skip = 0, long take = -1, Order order = Order.Ascending, SortType sortType = SortType.Numeric, /*RedisValue by = default, RedisValue[] get = null,*/ CommandFlags flags = CommandFlags.None) { //--- I don't know if serialization is necessary or not, so I will fix the default value. RedisValue by = default; RedisValue[] get = default; return(this.Connection.Database.SortAndStoreAsync(destination.Key, this.Key, skip, take, order, sortType, by, get, flags)); }
/// <summary> /// SDIFFSTORE : https://redis.io/commands/sdiffstore /// SINTERSTORE : https://redis.io/commands/sinterstore /// SUNIONSTORE : https://redis.io/commands/sunionstore /// </summary> /// <remarks> /// Combine self and other, then save it to the destination. /// It does not work unless you pass keys located the same server. /// </remarks> public Task <long> CombineAndStoreAsync(SetOperation operation, RedisSet <T> destination, IReadOnlyCollection <RedisSet <T> > others, CommandFlags flags = CommandFlags.None) { if (others == null) { throw new ArgumentNullException(nameof(others)); } if (others.Count == 0) { throw new ArgumentException("others length is 0."); } var keys = others.Select(x => x.Key).Concat(new [] { this.Key }).ToArray(); return(this.Connection.Database.SetCombineAndStoreAsync(operation, destination.Key, keys, flags)); }
/// <summary> /// SMOVE : https://redis.io/commands/smove /// </summary> public Task <bool> MoveAsync(RedisSet <T> destination, T value, CommandFlags flags = CommandFlags.None) { var serialized = this.Connection.Converter.Serialize(value); return(this.Connection.Database.SetMoveAsync(this.Key, destination.Key, serialized, flags)); }
/// <summary> /// SDIFF : https://redis.io/commands/sdiff /// SINTER : https://redis.io/commands/sinter /// SUNION : https://redis.io/commands/sunion /// </summary> /// <remarks>It does not work unless you pass keys located the same server.</remarks> public async Task <T[]> CombineAsync(SetOperation operation, RedisSet <T> other, CommandFlags flags = CommandFlags.None) { var values = await this.Connection.Database.SetCombineAsync(operation, this.Key, other.Key, flags).ConfigureAwait(false); return(values.Select(this.Connection.Converter, (x, c) => c.Deserialize <T>(x)).ToArray()); }
/// <summary> /// SDIFFSTORE : https://redis.io/commands/sdiffstore /// SINTERSTORE : https://redis.io/commands/sinterstore /// SUNIONSTORE : https://redis.io/commands/sunionstore /// </summary> /// <remarks> /// Combine self and other, then save it to the destination. /// It does not work unless you pass keys located the same server. /// </remarks> public Task <long> CombineAndStoreAsync(SetOperation operation, RedisSet <T> destination, RedisSet <T> other, CommandFlags flags = CommandFlags.None) => this.Connection.Database.SetCombineAndStoreAsync(operation, destination.Key, this.Key, other.Key, flags);