Hangfire.Redis.StackExchange icon indicating copy to clipboard operation
Hangfire.Redis.StackExchange copied to clipboard

Replace async Redis calls with sync ones

Open Lexy2 opened this issue 10 months ago • 0 comments

This is food for thought and invitation to discussion.

The library uses a mix of sync and async calls to Redis.

It's perfectly fine to use async calls in transactions. It's perfectly fine to use async calls with ContinueWith.

However, there are situations, where the same code is use both in transactions, and sequentially, but those calls are used in synchronous methods and are not awaited. This way, it is [theoretically] possible that the non-awaited task will be disposed before it is completed.

This call, for example: https://github.com/marcoCasamento/Hangfire.Redis.StackExchange/blob/master/Hangfire.Redis.StackExchange/RedisFetchedJob.cs#L69-L79 should be synchronous in non-transactional mode.

Lexy2 avatar Apr 22 '24 23:04 Lexy2