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
I noticed that the RedisConfiguration does not provide a way to specify the KeepAlive and ConnectRetry options, which are available in the ConfigurationOptions class of StackExchange.Redis.
Why is this the case and how do I specify this option?
Right now, I have an internal class which is bound with the JSON config. I then convert that into an instance of RedisConfiguration and do AddStackExchangeRedisExtensions. The reason for maintaining another class is that I don't want to have the shape of the JSON section depend on the shape of the extension class. I would rather have it separate so that I can control things better. In any case I eventually make a conversion to the required class.
I can't even set them during initialization and stuck with how to do this exactly.
A sample of what I do,
varconfigForExtension=newRedisConfiguration{AllowAdmin=myConfig.AllowAdmin,Ssl=myConfig.Ssl,ConnectTimeout=myConfig.ConnectTimeout,SyncTimeout=myConfig.SyncTimeout,AbortOnConnectFail=myConfig.AbortOnConnectFail,};varhosts=newList<RedisHost>();foreach(variteminmyConfig.Hosts){hosts.Add(newRedisHost{Host=item.Host,Port=item.Port});}configForExtension.Hosts=hosts.ToArray();// can't do this because it's a readonly field// configForExtension.ConfigurationOptions = new ConfigurationOptions(); // can't do this because at run time, the ConfigurationOptions would be NULL and result in exception// configForExtension.ConfigurationOptions.KeepAlive = 10;// configForExtension.ConfigurationOptions.ConnectRetry = 2;services.AddStackExchangeRedisExtensions<NewtonsoftSerializer>(configForExtension);
Any pointers would be appreciated. Thanks in advance.
OS: Windows
Runtime version: >NET 5
Version: 7.0.0
The text was updated successfully, but these errors were encountered:
I think the version I am using has some issue where Hosts is null on initialization, which in turn cases a problem when getting the ConfigurationOptions since we are iterating over private member hosts which could be null. In latest code I see its not the case so I'm suspecting this.
Because when I initialized Hosts to Array.Empty<RedisHost>() and tried configForExtension.ConfigurationOptions.KeepAlive. It worked.
But the original question still remains. Why KeepAlive and ConnectRetry are not present in the top level configuration class and not even populated when you create the StackExchange.Redis.ConfigurationOptions
I feel it might be good expose a way to set ConfigurationOptions. What is the significance of the other RedisConfiguration when finally, its the ConfigurationOptions which matters. Please let me know if i am missing something with the intended use.
I noticed that the
RedisConfiguration
does not provide a way to specify theKeepAlive
andConnectRetry
options, which are available in theConfigurationOptions
class ofStackExchange.Redis
.Why is this the case and how do I specify this option?
Right now, I have an internal class which is bound with the JSON config. I then convert that into an instance of
RedisConfiguration
and doAddStackExchangeRedisExtensions
. The reason for maintaining another class is that I don't want to have the shape of the JSON section depend on the shape of the extension class. I would rather have it separate so that I can control things better. In any case I eventually make a conversion to the required class.I can't even set them during initialization and stuck with how to do this exactly.
A sample of what I do,
Any pointers would be appreciated. Thanks in advance.
The text was updated successfully, but these errors were encountered: