Skip to content

Commit 1ae0f78

Browse files
committed
Simplify by removing field
1 parent adc3052 commit 1ae0f78

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

osu.Server.QueueProcessor/QueueProcessor.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ public abstract class QueueProcessor<T> where T : QueueItem
4848

4949
private readonly Lazy<IDatabase> redis = new Lazy<IDatabase>(() => RedisAccess.GetConnection().GetDatabase());
5050

51-
/// <summary>
52-
/// Separate redis instance (connection) dedicated to blocking calls.
53-
/// Must not be accessed from more than one thread. Currently used only in <see cref="Run"/>.
54-
/// This is a workaround for <c>StackExchange.Redis</c> not offering support for operations like <c>BRPOP</c>.
55-
/// </summary>
56-
private readonly Lazy<IDatabase> blockingRedis = new Lazy<IDatabase>(() => RedisAccess.GetConnection().GetDatabase());
57-
5851
/// <summary>
5952
/// Access redis instance.
6053
/// </summary>
@@ -92,6 +85,9 @@ protected QueueProcessor(QueueConfiguration config)
9285
/// <param name="cancellation">An optional cancellation token.</param>
9386
public void Run(CancellationToken cancellation = default)
9487
{
88+
// dedicated redis connection for the BRPOP path, workaround for StackExchange.Redis not offering blocking operations
89+
var blockingRedis = new Lazy<IDatabase>(() => RedisAccess.GetConnection().GetDatabase());
90+
9591
using (SentrySdk.Init(setupSentry))
9692
using (new Timer(_ => outputStats(), null, TimeSpan.Zero, TimeSpan.FromSeconds(5)))
9793
using (var cts = new GracefulShutdownSource(cancellation))
@@ -118,7 +114,7 @@ public void Run(CancellationToken cancellation = default)
118114

119115
if (config.UseBlockingPop)
120116
{
121-
// timeout in seconds, can't be higher than the Redis library timeout (default is 5 seconds)
117+
// timeout in seconds, can't be higher than StackExchange.Redis timeout (default is 5 seconds)
122118
const string timeout = "1";
123119

124120
RedisResult redisResult = blockingRedis.Value.Execute("BRPOP", QueueName, timeout);

0 commit comments

Comments
 (0)