File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed
src/Caching/StackExchangeRedis/src Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 11#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()
199199 {
200200 _connection = ConnectionMultiplexer . Connect ( _options . Configuration ) ;
201201 }
202+
203+ TryRegisterProfiler ( ) ;
202204 _cache = _connection . GetDatabase ( ) ;
203205 }
204206 }
@@ -232,6 +234,7 @@ private void Connect()
232234 _connection = await ConnectionMultiplexer . ConnectAsync ( _options . Configuration ) . ConfigureAwait ( false ) ;
233235 }
234236
237+ TryRegisterProfiler ( ) ;
235238 _cache = _connection . GetDatabase ( ) ;
236239 }
237240 }
@@ -241,6 +244,14 @@ private void Connect()
241244 }
242245 }
243246
247+ private void TryRegisterProfiler ( )
248+ {
249+ if ( _connection != null && _options . ProfilingSession != null )
250+ {
251+ _connection . RegisterProfiler ( _options . ProfilingSession ) ;
252+ }
253+ }
254+
244255 private byte [ ] GetAndRefresh ( string key , bool getData )
245256 {
246257 if ( key == null )
Original file line number Diff line number Diff line change 22// The .NET Foundation licenses this file to you under the MIT license.
33// See the LICENSE file in the project root for more information.
44
5+ using System ;
56using Microsoft . Extensions . Options ;
67using StackExchange . Redis ;
8+ using StackExchange . Redis . Profiling ;
79
810namespace Microsoft . Extensions . Caching . StackExchangeRedis
911{
@@ -28,9 +30,14 @@ public class RedisCacheOptions : IOptions<RedisCacheOptions>
2830 /// </summary>
2931 public string InstanceName { get ; set ; }
3032
33+ /// <summary>
34+ /// The Redis profiling session
35+ /// </summary>
36+ public Func < ProfilingSession > ProfilingSession { get ; set ; }
37+
3138 RedisCacheOptions IOptions < RedisCacheOptions > . Value
3239 {
3340 get { return this ; }
3441 }
3542 }
36- }
43+ }
You can’t perform that action at this time.
0 commit comments