Describe the bug
IRedisDatabase.GetAsync<T> states that it returns T? (nullable) and null if not present. But when I use it with a value type (int, bool), the method actually returns default of that value type when called like this:
IRedisDatabase.GetAsync<int> returns 0 (I would expect null)
IRedisDatabase.GetAsync<int?> returns null correctly
This contradicts the documentation of the method
To Reproduce
var redisConfig = new RedisConfiguration
{
AbortOnConnectFail = false,
ConnectionString = redisConnectionString,
AllowAdmin = true,
ConnectTimeout = 3000,
SyncTimeout = 2000,
Database = 0,
Ssl = true,
PoolSize = 5,
IsDefault = true,
Name = serviceName
};
var serializer = new SystemTextJsonSerializer(OrionJsonOptions.Default);
var redisClientFactory = new RedisClientFactory(redisConfig, loggerFactory, serializer);
var redisDatabase = redisClientFactory
.GetDefaultRedisClient()
.GetDefaultDatabase();
Following Calls should imho both return null
var badValue = await redisDatabase.GetAsync<int>("SomeKey"); // returns 0
var goodValue = await redisDatabase.GetAsync<int?>("SomeKey"); // returns null
Expected behavior
Both calls return null because the signature is
Task<T?> GetAsync<T>(string key, CommandFlags flag = CommandFlags.None);
Desktop (please complete the following information):
- OS: MacOS
- Runtime version .NET Core 9
- Version 8.0.3
Additional context
- So far I observed this behavior on MacOS
Describe the bug
IRedisDatabase.GetAsync<T>states that it returnsT?(nullable) and null if not present. But when I use it with a value type (int, bool), the method actually returnsdefaultof that value type when called like this:This contradicts the documentation of the method
To Reproduce
Following Calls should imho both return null
Expected behavior
Both calls return null because the signature is
Task<T?> GetAsync<T>(string key, CommandFlags flag = CommandFlags.None);Desktop (please complete the following information):
Additional context