@@ -25,7 +25,8 @@ for a recommendation. Use the checklist icons to record your
2525progress in implementing the recommendations.
2626
2727{{< checklist "dotnetprodlist" >}}
28- {{< checklist-item "#server-maintenance-event-handling" >}}Server maintenance event handling{{< /checklist-item >}}
28+ {{< checklist-item "#event-handling" >}}Event handling{{< /checklist-item >}}
29+ {{< checklist-item "#timeouts" >}}Timeouts{{< /checklist-item >}}
2930 {{< checklist-item "#exception-handling" >}}Exception handling{{< /checklist-item >}}
3031{{< /checklist >}}
3132
@@ -34,7 +35,19 @@ progress in implementing the recommendations.
3435The sections below offer recommendations for your production environment. Some
3536of them may not apply to your particular use case.
3637
37- ### Server maintenance event handling
38+ ### Event handling
39+
40+ The ` ConnectionMultiplexer ` class publishes several different types of
41+ [ events] ( https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/events/ )
42+ for situations such as configuration changes and connection failures.
43+ Use these events to record server activity in a log, which you can then use
44+ to monitor performance and diagnose problems when they occur.
45+ See
46+ the StackExchange.Redis
47+ [ Events] ( https://stackexchange.github.io/StackExchange.Redis/Events )
48+ page for the full list of events.
49+
50+ #### Server notification events
3851
3952Some servers (such as Azure Cache for Redis) send notification events shortly
4053before scheduled maintenance is due to happen. You can use code like the
@@ -56,6 +69,33 @@ muxer.ServerMaintenanceEvent += (object sender, ServerMaintenanceEvent e) => {
5669};
5770```
5871
72+ ### Timeouts
73+
74+ If a network or server error occurs while your code is opening a
75+ connection or issuing a command, it can end up hanging indefinitely.
76+ To prevent this, ` NRedisStack ` sets timeouts for socket
77+ reads and writes and for opening connections.
78+
79+ By default, the timeout is five seconds for all operations, but
80+ you can set the time (in milliseconds) separately for connections
81+ and commands using the ` ConnectTimeout ` , ` SyncTimeout ` , and
82+ ` AsyncTimeout ` configuration options:
83+
84+ ``` cs
85+ var muxer = ConnectionMultiplexer .Connect (new ConfigurationOptions {
86+ ConnectTimeout = 1000 , // 1 second timeout for connections.
87+ SyncTimeout = 2000 , // 2 seconds for synchronous commands.
88+ AsyncTimeout = 3000 // 3 seconds for asynchronous commands.
89+ .
90+ .
91+ });
92+
93+ var db = muxer .GetDatabase ();
94+ ```
95+
96+ The default timeouts are a good starting point, but you may be able
97+ to improve performance by adjusting the values to suit your use case.
98+
5999### Exception handling
60100
61101Redis handles many errors using return values from commands, but there
0 commit comments