Skip to content

Commit

Permalink
Cleaned up parameters for clear queue
Browse files Browse the repository at this point in the history
  • Loading branch information
gregyjames committed Feb 19, 2024
1 parent b4b7a46 commit 41784b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions ReQueue/MessageQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ internal MessageQueue(IDatabase database, string redisKey)
/// <returns></returns>
public async Task EnqueueMessages(T item)
{
byte[] bytes = MessagePackSerializer.Serialize(item);
string base64String = Convert.ToBase64String(bytes);
var bytes = MessagePackSerializer.Serialize(item);
var base64String = Convert.ToBase64String(bytes);
await _db.ListLeftPushAsync(_redisKey, base64String);
}

Expand All @@ -50,8 +50,8 @@ public async Task DequeueMessages(Action<T> action, CancellationToken cancellati
if (result != RedisValue.Null)
{
// Process the item
string item = result.ToString();
byte[] decodedData = Convert.FromBase64String(item);
var item = result.ToString();
var decodedData = Convert.FromBase64String(item);
var deserialized = MessagePackSerializer.Deserialize<T>(decodedData);

if(filter != null)
Expand Down Expand Up @@ -84,11 +84,10 @@ public async Task DequeueMessages(Action<T> action, CancellationToken cancellati
/// <summary>
/// Clears all unprocessed items from the queue.
/// </summary>
/// <param name="queueKey">The name of the queue.</param>
/// <returns></returns>
public async Task ClearQueue(string queueKey)
public async Task ClearQueue()
{
await _db.KeyDeleteAsync(queueKey);
await _db.KeyDeleteAsync(_redisKey);
}
}
}
2 changes: 1 addition & 1 deletion ReQueueClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static async Task Main(string[] args)
}, tokenSource.Token, (data) => data.Foo % 2 != 0)
);

await queue.ClearQueue("numQueue");
await queue.ClearQueue();
Console.ReadLine();
}
}
Expand Down

0 comments on commit 41784b7

Please sign in to comment.