File tree 3 files changed +21
-1
lines changed
src/Caching/StackExchangeRedis/src
3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 1
1
#nullable enable
2
+ ~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.ProfilingSession.get -> System.Func<StackExchange.Redis.Profiling.ProfilingSession>
3
+ ~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.ProfilingSession.set -> void
Original file line number Diff line number Diff line change @@ -199,6 +199,8 @@ private void Connect()
199
199
{
200
200
_connection = ConnectionMultiplexer . Connect ( _options . Configuration ) ;
201
201
}
202
+
203
+ TryRegisterProfiler ( ) ;
202
204
_cache = _connection . GetDatabase ( ) ;
203
205
}
204
206
}
@@ -232,6 +234,7 @@ private void Connect()
232
234
_connection = await ConnectionMultiplexer . ConnectAsync ( _options . Configuration ) . ConfigureAwait ( false ) ;
233
235
}
234
236
237
+ TryRegisterProfiler ( ) ;
235
238
_cache = _connection . GetDatabase ( ) ;
236
239
}
237
240
}
@@ -241,6 +244,14 @@ private void Connect()
241
244
}
242
245
}
243
246
247
+ private void TryRegisterProfiler ( )
248
+ {
249
+ if ( _connection != null && _options . ProfilingSession != null )
250
+ {
251
+ _connection . RegisterProfiler ( _options . ProfilingSession ) ;
252
+ }
253
+ }
254
+
244
255
private byte [ ] GetAndRefresh ( string key , bool getData )
245
256
{
246
257
if ( key == null )
Original file line number Diff line number Diff line change 2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
// See the LICENSE file in the project root for more information.
4
4
5
+ using System ;
5
6
using Microsoft . Extensions . Options ;
6
7
using StackExchange . Redis ;
8
+ using StackExchange . Redis . Profiling ;
7
9
8
10
namespace Microsoft . Extensions . Caching . StackExchangeRedis
9
11
{
@@ -28,9 +30,14 @@ public class RedisCacheOptions : IOptions<RedisCacheOptions>
28
30
/// </summary>
29
31
public string InstanceName { get ; set ; }
30
32
33
+ /// <summary>
34
+ /// The Redis profiling session
35
+ /// </summary>
36
+ public Func < ProfilingSession > ProfilingSession { get ; set ; }
37
+
31
38
RedisCacheOptions IOptions < RedisCacheOptions > . Value
32
39
{
33
40
get { return this ; }
34
41
}
35
42
}
36
- }
43
+ }
You can’t perform that action at this time.
0 commit comments