You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I'm trying to implement the cache aside strategy with negative (null) caching supported.
Currently, there is no way to know if the default value is cached or not in a single round trip. I need to use a combination of the GetAsync & the ExistsAsync method on the ICache to know the difference.
This can cause issues when multiple executions access the cache concurrently. It might occur that the cache is updated (due to another exeuction) in between both calls, resulting in strange behavior.
Describe the solution you'd like
It would be nice if there was an option to know the difference between a cache miss (key not found in cache) and a negative cache result (key found in cache with default value) in a single atomic operation.
The text was updated successfully, but these errors were encountered:
int?num=await redisDb.GetAsync<int?>(key);// null means the value does not exist// 0 means the value is default
Cached value is RefType
When the value is null, the Redis side normally caches an empty byte array based on the serializer.
A workaround is using the exposed StackExchange.Redis.IDatabase property of IRedisDatabase. For example,
RedisValuestr=await redisDb.Database.StringGetAsync(key);// If RedisValue.IsNull is true, the value does not exist// If not, check whether the value is empty string.// Afterwards, if the value is a complex object, you have to deserialize it manually.
Is your feature request related to a problem? Please describe.
I'm trying to implement the cache aside strategy with negative (null) caching supported.
Currently, there is no way to know if the default value is cached or not in a single round trip. I need to use a combination of the
GetAsync
& theExistsAsync
method on theICache
to know the difference.This can cause issues when multiple executions access the cache concurrently. It might occur that the cache is updated (due to another exeuction) in between both calls, resulting in strange behavior.
Describe the solution you'd like
It would be nice if there was an option to know the difference between a cache miss (key not found in cache) and a negative cache result (key found in cache with default value) in a single atomic operation.
The text was updated successfully, but these errors were encountered: