@@ -27,6 +27,7 @@ public partial class MemcachedClient : IMemcachedClient, IMemcachedResultsClient
27
27
public static readonly TimeSpan Infinite = TimeSpan . Zero ;
28
28
//internal static readonly MemcachedClientSection DefaultSettings = ConfigurationManager.GetSection("enyim.com/memcached") as MemcachedClientSection;
29
29
private ILogger < MemcachedClient > _logger ;
30
+ private bool _suppressException ;
30
31
31
32
private IServerPool pool ;
32
33
private IMemcachedKeyTransformer keyTransformer ;
@@ -51,6 +52,7 @@ public MemcachedClient(ILoggerFactory loggerFactory, IMemcachedClientConfigurati
51
52
throw new ArgumentNullException ( nameof ( configuration ) ) ;
52
53
}
53
54
55
+ _suppressException = configuration . SuppressException ;
54
56
this . keyTransformer = configuration . CreateKeyTransformer ( ) ?? new DefaultKeyTransformer ( ) ;
55
57
this . transcoder = configuration . CreateTranscoder ( ) ?? new DefaultTranscoder ( ) ;
56
58
@@ -154,7 +156,10 @@ public IGetOperationResult<T> PerformGet<T>(string key)
154
156
}
155
157
catch ( Exception ex )
156
158
{
159
+
157
160
_logger . LogError ( 0 , ex , $ "{ nameof ( PerformGet ) } (\" { key } \" )") ;
161
+ if ( ! _suppressException ) throw ;
162
+
158
163
result . Fail ( ex . Message ) ;
159
164
return result ;
160
165
}
@@ -246,6 +251,8 @@ public async Task<IGetOperationResult> GetAsync(string key)
246
251
catch ( Exception ex )
247
252
{
248
253
_logger . LogError ( 0 , ex , $ "{ nameof ( GetAsync ) } (\" { key } \" )") ;
254
+ if ( ! _suppressException ) throw ;
255
+
249
256
result . Fail ( ex . Message , ex ) ;
250
257
return result ;
251
258
}
@@ -267,6 +274,8 @@ public async Task<IGetOperationResult<T>> GetAsync<T>(string key)
267
274
catch ( Exception ex )
268
275
{
269
276
_logger . LogError ( 0 , ex , $ "{ nameof ( GetAsync ) } (\" { key } \" )") ;
277
+ if ( ! _suppressException ) throw ;
278
+
270
279
result . Fail ( ex . Message , ex ) ;
271
280
return result ;
272
281
}
@@ -300,6 +309,7 @@ public async Task<T> GetValueOrCreateAsync<T>(string key, int cacheSeconds, Func
300
309
catch ( Exception ex )
301
310
{
302
311
_logger . LogError ( ex , $ "{ nameof ( AddAsync ) } (\" { key } \" , ..., { cacheSeconds } )") ;
312
+ if ( ! _suppressException ) throw ;
303
313
}
304
314
}
305
315
return value ;
@@ -594,6 +604,7 @@ protected virtual IStoreOperationResult PerformStore(StoreMode mode, string key,
594
604
catch ( Exception e )
595
605
{
596
606
_logger . LogError ( "PerformStore" , e ) ;
607
+ if ( ! _suppressException ) throw ;
597
608
598
609
result . Fail ( "PerformStore failed" , e ) ;
599
610
return result ;
@@ -1221,6 +1232,7 @@ protected virtual IDictionary<string, T> PerformMultiGet<T>(IEnumerable<string>
1221
1232
catch ( Exception e )
1222
1233
{
1223
1234
_logger . LogError ( 0 , e , "PerformMultiGet" ) ;
1235
+ if ( ! _suppressException ) throw ;
1224
1236
}
1225
1237
} ) ) ;
1226
1238
}
0 commit comments