Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- fix potential errors getting socket bytes (#1836 via NickCraver)
- logging additions (.NET Version and timestamps) for better debugging (#1796 via philon-msft)
- add: `Condition` API (transactions) now supports `StreamLengthEqual` and variants (#1807 via AlphaGremlin)
- Add support for count argument to `ListLeftPop`, `ListLeftPopAsync`, `ListRightPop`, and `ListRightPopAsync` (#1850 via jjfmarket)
- fix potential task/thread exhaustion from the backlog processor (#1854 via mgravell)

## 2.2.62
Expand Down
22 changes: 22 additions & 0 deletions src/StackExchange.Redis/Interfaces/IDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,17 @@ public interface IDatabase : IRedis, IDatabaseAsync
/// <remarks>https://redis.io/commands/lpop</remarks>
RedisValue ListLeftPop(RedisKey key, CommandFlags flags = CommandFlags.None);

/// <summary>
/// Removes and returns count elements from the tail of the list stored at key.
/// If there are less elements in the list than count, removes and returns all the elements in the list.
/// </summary>
/// <param name="key">The key of the list.</param>
/// <param name="count">The number of items to remove.</param>
/// <param name="flags">The flags to use for this operation.</param>
/// <returns>Array of values that were popped, or nil if the key doesn't exist.</returns>
/// <remarks>https://redis.io/commands/lpop</remarks>
RedisValue[] ListLeftPop(RedisKey key, long count, CommandFlags flags = CommandFlags.None);

/// <summary>
/// Insert the specified value at the head of the list stored at key. If key does not exist, it is created as empty list before performing the push operations.
/// </summary>
Expand Down Expand Up @@ -719,6 +730,17 @@ public interface IDatabase : IRedis, IDatabaseAsync
/// <remarks>https://redis.io/commands/rpop</remarks>
RedisValue ListRightPop(RedisKey key, CommandFlags flags = CommandFlags.None);

/// <summary>
/// Removes and returns count elements from the head of the list stored at key.
/// If there are less elements in the list than count, removes and returns all the elements in the list.
/// </summary>
/// <param name="key">The key of the list.</param>
/// <param name="count">tThe number of items to remove.</param>
/// <param name="flags">The flags to use for this operation.</param>
/// <returns>Array of values that were popped, or nil if the key doesn't exist.</returns>
/// <remarks>https://redis.io/commands/rpop</remarks>
RedisValue[] ListRightPop(RedisKey key, long count, CommandFlags flags = CommandFlags.None);

/// <summary>
/// Atomically returns and removes the last element (tail) of the list stored at source, and pushes the element at the first element (head) of the list stored at destination.
/// </summary>
Expand Down
22 changes: 22 additions & 0 deletions src/StackExchange.Redis/Interfaces/IDatabaseAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,17 @@ public interface IDatabaseAsync : IRedisAsync
/// <remarks>https://redis.io/commands/lpop</remarks>
Task<RedisValue> ListLeftPopAsync(RedisKey key, CommandFlags flags = CommandFlags.None);

/// <summary>
/// Removes and returns count elements from the head of the list stored at key.
/// If the list contains less than count elements, removes and returns the number of elements in the list
/// </summary>
/// <param name="key">The key of the list.</param>
/// <param name="count">The number of elements to remove</param>
/// <param name="flags">The flags to use for this operation.</param>
/// <returns>Array of values that were popped, or nil if the key doesn't exist</returns>
/// <remarks>https://redis.io/commands/lpop</remarks>
Task<RedisValue[]> ListLeftPopAsync(RedisKey key, long count, CommandFlags flags = CommandFlags.None);

/// <summary>
/// Insert the specified value at the head of the list stored at key. If key does not exist, it is created as empty list before performing the push operations.
/// </summary>
Expand Down Expand Up @@ -696,6 +707,17 @@ public interface IDatabaseAsync : IRedisAsync
/// <remarks>https://redis.io/commands/rpop</remarks>
Task<RedisValue> ListRightPopAsync(RedisKey key, CommandFlags flags = CommandFlags.None);

/// <summary>
/// Removes and returns count elements from the end the list stored at key.
/// If the list contains less than count elements, removes and returns the number of elements in the list
/// </summary>
/// <param name="key">The key of the list.</param>
/// <param name="count">The number of elements to pop</param>
/// <param name="flags">The flags to use for this operation.</param>
/// <returns>Array of values that were popped, or nil if the key doesn't exist</returns>
/// <remarks>https://redis.io/commands/rpop</remarks>
Task<RedisValue[]> ListRightPopAsync(RedisKey key, long count, CommandFlags flags = CommandFlags.None);

/// <summary>
/// Atomically returns and removes the last element (tail) of the list stored at source, and pushes the element at the first element (head) of the list stored at destination.
/// </summary>
Expand Down
10 changes: 10 additions & 0 deletions src/StackExchange.Redis/KeyspaceIsolation/DatabaseWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ public RedisValue ListLeftPop(RedisKey key, CommandFlags flags = CommandFlags.No
return Inner.ListLeftPop(ToInner(key), flags);
}

public RedisValue[] ListLeftPop(RedisKey key, long count, CommandFlags flags = CommandFlags.None)
{
return Inner.ListLeftPop(ToInner(key), count, flags);
}

public long ListLeftPush(RedisKey key, RedisValue[] values, CommandFlags flags = CommandFlags.None)
{
return Inner.ListLeftPush(ToInner(key), values, flags);
Expand Down Expand Up @@ -336,6 +341,11 @@ public RedisValue ListRightPop(RedisKey key, CommandFlags flags = CommandFlags.N
return Inner.ListRightPop(ToInner(key), flags);
}

public RedisValue[] ListRightPop(RedisKey key, long count, CommandFlags flags = CommandFlags.None)
{
return Inner.ListRightPop(ToInner(key), count, flags);
}

public RedisValue ListRightPopLeftPush(RedisKey source, RedisKey destination, CommandFlags flags = CommandFlags.None)
{
return Inner.ListRightPopLeftPush(ToInner(source), ToInner(destination), flags);
Expand Down
10 changes: 10 additions & 0 deletions src/StackExchange.Redis/KeyspaceIsolation/WrapperBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,11 @@ public Task<RedisValue> ListLeftPopAsync(RedisKey key, CommandFlags flags = Comm
return Inner.ListLeftPopAsync(ToInner(key), flags);
}

public Task<RedisValue[]> ListLeftPopAsync(RedisKey key, long count, CommandFlags flags = CommandFlags.None)
{
return Inner.ListLeftPopAsync(ToInner(key), count, flags);
}

public Task<long> ListLeftPushAsync(RedisKey key, RedisValue[] values, CommandFlags flags = CommandFlags.None)
{
return Inner.ListLeftPushAsync(ToInner(key), values, flags);
Expand Down Expand Up @@ -321,6 +326,11 @@ public Task<RedisValue> ListRightPopAsync(RedisKey key, CommandFlags flags = Com
return Inner.ListRightPopAsync(ToInner(key), flags);
}

public Task<RedisValue[]> ListRightPopAsync(RedisKey key, long count, CommandFlags flags = CommandFlags.None)
{
return Inner.ListRightPopAsync(ToInner(key), count, flags);
}

public Task<RedisValue> ListRightPopLeftPushAsync(RedisKey source, RedisKey destination, CommandFlags flags = CommandFlags.None)
{
return Inner.ListRightPopLeftPushAsync(ToInner(source), ToInner(destination), flags);
Expand Down
30 changes: 27 additions & 3 deletions src/StackExchange.Redis/RedisDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -922,12 +922,24 @@ public RedisValue ListLeftPop(RedisKey key, CommandFlags flags = CommandFlags.No
return ExecuteSync(msg, ResultProcessor.RedisValue);
}

public RedisValue[] ListLeftPop(RedisKey key, long count, CommandFlags flags = CommandFlags.None)
{
var msg = Message.Create(Database, flags, RedisCommand.LPOP, key, count);
return ExecuteSync(msg, ResultProcessor.RedisValueArray);
}

public Task<RedisValue> ListLeftPopAsync(RedisKey key, CommandFlags flags = CommandFlags.None)
{
var msg = Message.Create(Database, flags, RedisCommand.LPOP, key);
return ExecuteAsync(msg, ResultProcessor.RedisValue);
}

public Task<RedisValue[]> ListLeftPopAsync(RedisKey key, long count, CommandFlags flags = CommandFlags.None)
{
var msg = Message.Create(Database, flags, RedisCommand.LPOP, key, count);
return ExecuteAsync(msg, ResultProcessor.RedisValueArray);
}

public long ListLeftPush(RedisKey key, RedisValue value, When when = When.Always, CommandFlags flags = CommandFlags.None)
{
WhenAlwaysOrExists(when);
Expand Down Expand Up @@ -1016,12 +1028,24 @@ public RedisValue ListRightPop(RedisKey key, CommandFlags flags = CommandFlags.N
return ExecuteSync(msg, ResultProcessor.RedisValue);
}

public RedisValue[] ListRightPop(RedisKey key, long count, CommandFlags flags = CommandFlags.None)
{
var msg = Message.Create(Database, flags, RedisCommand.RPOP, key, count);
return ExecuteSync(msg, ResultProcessor.RedisValueArray);
}

public Task<RedisValue> ListRightPopAsync(RedisKey key, CommandFlags flags = CommandFlags.None)
{
var msg = Message.Create(Database, flags, RedisCommand.RPOP, key);
return ExecuteAsync(msg, ResultProcessor.RedisValue);
}

public Task<RedisValue[]> ListRightPopAsync(RedisKey key, long count, CommandFlags flags = CommandFlags.None)
{
var msg = Message.Create(Database, flags, RedisCommand.RPOP, key, count);
return ExecuteAsync(msg, ResultProcessor.RedisValueArray);
}

public RedisValue ListRightPopLeftPush(RedisKey source, RedisKey destination, CommandFlags flags = CommandFlags.None)
{
var msg = Message.Create(Database, flags, RedisCommand.RPOPLPUSH, source, destination);
Expand Down Expand Up @@ -1933,7 +1957,7 @@ public bool StreamCreateConsumerGroup(RedisKey key, RedisValue groupName, RedisV
key,
groupName,
position,
true,
true,
flags);
}

Expand Down Expand Up @@ -2251,7 +2275,7 @@ public Task<StreamEntry[]> StreamReadGroupAsync(RedisKey key, RedisValue groupNa
false,
flags);
}

public Task<StreamEntry[]> StreamReadGroupAsync(RedisKey key, RedisValue groupName, RedisValue consumerName, RedisValue? position = null, int? count = null, bool noAck = false, CommandFlags flags = CommandFlags.None)
{
var actualPosition = position ?? StreamPosition.NewMessages;
Expand Down Expand Up @@ -2815,7 +2839,7 @@ private Message GetMultiStreamReadMessage(StreamPosition[] streamPositions, int?
* [7] = id1
* [8] = id2
* [9] = id3
*
*
* */

var pairCount = streamPositions.Length;
Expand Down
14 changes: 14 additions & 0 deletions tests/StackExchange.Redis.Tests/DatabaseWrapperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,13 @@ public void ListLeftPop()
mock.Verify(_ => _.ListLeftPop("prefix:key", CommandFlags.None));
}

[Fact]
public void ListLeftPop_1()
{
wrapper.ListLeftPop("key", 123, CommandFlags.None);
mock.Verify(_ => _.ListLeftPop("prefix:key", 123, CommandFlags.None));
}

[Fact]
public void ListLeftPush_1()
{
Expand Down Expand Up @@ -420,6 +427,13 @@ public void ListRightPop()
mock.Verify(_ => _.ListRightPop("prefix:key", CommandFlags.None));
}

[Fact]
public void ListRightPop_1()
{
wrapper.ListRightPop("key", 123, CommandFlags.None);
mock.Verify(_ => _.ListRightPop("prefix:key", 123, CommandFlags.None));
}

[Fact]
public void ListRightPopLeftPush()
{
Expand Down
14 changes: 14 additions & 0 deletions tests/StackExchange.Redis.Tests/WrapperBaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,13 @@ public void ListLeftPopAsync()
mock.Verify(_ => _.ListLeftPopAsync("prefix:key", CommandFlags.None));
}

[Fact]
public void ListLeftPopAsync_1()
{
wrapper.ListLeftPopAsync("key", 123, CommandFlags.None);
mock.Verify(_ => _.ListLeftPopAsync("prefix:key", 123, CommandFlags.None));
}

[Fact]
public void ListLeftPushAsync_1()
{
Expand Down Expand Up @@ -381,6 +388,13 @@ public void ListRightPopAsync()
mock.Verify(_ => _.ListRightPopAsync("prefix:key", CommandFlags.None));
}

[Fact]
public void ListRightPopAsync_1()
{
wrapper.ListRightPopAsync("key", 123, CommandFlags.None);
mock.Verify(_ => _.ListRightPopAsync("prefix:key", 123, CommandFlags.None));
}

[Fact]
public void ListRightPopLeftPushAsync()
{
Expand Down