22{
33 using EasyCaching . Core ;
44 using EasyCaching . Core . DistributedLock ;
5- using EasyCaching . Memcached . DistributedLock ;
5+ using EasyCaching . Memcached . DistributedLock ;
66 using Microsoft . Extensions . Logging ;
77 using System ;
88 using System . Collections . Generic ;
@@ -157,9 +157,9 @@ public override CacheValue<T> BaseGet<T>(string cacheKey)
157157 {
158158 ArgumentCheck . NotNullOrWhiteSpace ( cacheKey , nameof ( cacheKey ) ) ;
159159
160- var data = _memcachedClient . PerformGet < T > ( this . HandleCacheKey ( cacheKey ) ) ;
160+ var data = _memcachedClient . PerformGet < object > ( this . HandleCacheKey ( cacheKey ) ) ;
161161
162- if ( ! data . Success ) throw new EasyCachingException ( $ "opereation fail { data . Message } " , data . Exception ) ;
162+ CheckResult ( data ) ;
163163
164164 var result = ConvertFromStoredValue < T > ( data . Value ) ;
165165
@@ -186,7 +186,7 @@ public override void BaseRemove(string cacheKey)
186186
187187 var data = _memcachedClient . ExecuteRemove ( this . HandleCacheKey ( cacheKey ) ) ;
188188
189- if ( ! data . Success ) throw new EasyCachingException ( $ "opereation fail { data . Message } " , data . Exception ) ;
189+ CheckResult ( data ) ;
190190 }
191191
192192 /// <summary>
@@ -215,7 +215,7 @@ public override void BaseSet<T>(string cacheKey, T cacheValue, TimeSpan expirati
215215 this . ConvertToStoredValue ( cacheValue ) ,
216216 expiration ) ;
217217
218- if ( ! data . Success ) throw new EasyCachingException ( $ "opereation fail { data . Message } " , data . Exception ) ;
218+ CheckResult ( data ) ;
219219 }
220220
221221 /// <summary>
@@ -261,7 +261,7 @@ public override void BaseRemoveByPrefix(string prefix)
261261 newValue ,
262262 new TimeSpan ( 0 , 0 , 0 ) ) ;
263263
264- if ( ! data . Success ) throw new EasyCachingException ( $ "opereation fail { data . Message } " , data . Exception ) ;
264+ CheckResult ( data ) ;
265265 }
266266
267267 /// <summary>
@@ -442,5 +442,13 @@ private void OnCacheMiss(string cacheKey)
442442 if ( _options . EnableLogging )
443443 _logger ? . LogInformation ( $ "Cache Missed : cachekey = { cacheKey } ") ;
444444 }
445+
446+ private void CheckResult ( Enyim . Caching . Memcached . Results . IOperationResult data )
447+ {
448+ if ( ! data . Success
449+ && ( ! data . InnerResult ? . Success ?? false )
450+ && ( data . InnerResult ? . Message ? . Contains ( "Failed to create socket" ) ?? false ) )
451+ throw new EasyCachingException ( $ "opereation fail, { data . InnerResult ? . Message ?? "" } ", data . Exception ) ;
452+ }
445453 }
446454}
0 commit comments