Closed marcinmilik closed 3 years ago
Hi, that is very weird. Essentially you are saying that between line 130 and 133 if the key expires then we have an issue and throws exception?
To be more precise we think that in that case value
variable contains null value and line 134 throws the provided exception:
https://github.com/aliostad/CacheCow/blob/ed492bcb92b3582bedc043d5205dbdacf6f03ab7/src/CacheCow.Client.RedisCacheStore/RedisStore.cs#L134
As MemoryStream constructor does not accept null parameter.
That's what we think. At least we have not found better explanation for the provided exception.
Ah now it makes sense.
OK, that is a bug. I still believe it is a race condition which is likely but I will fix and push the next version to nuget.
Thanks for spotting it!
This is done now. I close the issue, any problems though let me know.
We observed the issue with RedisCacheStore:
Most of the time it works well. We did a small analyze and it looks that the reason may be that entryKey expired just after the check if it exists: https://github.com/aliostad/CacheCow/blob/ed492bcb92b3582bedc043d5205dbdacf6f03ab7/src/CacheCow.Client.RedisCacheStore/RedisStore.cs#L130-L133
How about the improvement to skip
KeyExistsAsync
check. And only compare if result fromStringGetAsync
has value? Or checking if byte[] values is not null?It looks that the similar solution was applied with success on another project. Please check that for details: https://github.com/MiniProfiler/dotnet/issues/245