@@ -75,7 +75,7 @@ public class AbpHybridCache<TCacheItem, TCacheKey> : IHybridCache<TCacheItem, TC
7575
7676 protected HybridCache HybridCache { get ; }
7777
78- protected IDistributedCache DistributedCacheCache { get ; }
78+ protected IDistributedCache DistributedCache { get ; }
7979
8080 protected ICancellationTokenProvider CancellationTokenProvider { get ; }
8181
@@ -105,7 +105,7 @@ public AbpHybridCache(
105105 ServiceProvider = serviceProvider ;
106106 DistributedCacheOption = distributedCacheOption . Value ;
107107 HybridCache = hybridCache ;
108- DistributedCacheCache = distributedCache ;
108+ DistributedCache = distributedCache ;
109109 CancellationTokenProvider = cancellationTokenProvider ;
110110 Logger = NullLogger < AbpHybridCache < TCacheItem , TCacheKey > > . Instance ;
111111 KeyNormalizer = keyNormalizer ;
@@ -215,10 +215,15 @@ protected virtual void SetDefaultOptions()
215215 }
216216 }
217217
218- var bytes = await DistributedCacheCache . GetAsync ( NormalizeKey ( key ) , token ) ;
219- if ( bytes != null )
218+ if ( await DistributedCache . GetAsync ( NormalizeKey ( key ) , token ) != null )
220219 {
221- return ResolveSerializer ( ) . Deserialize ( new ReadOnlySequence < byte > ( bytes , 0 , bytes . Length ) ) ; ;
220+ // Because HybridCache wraps the cache in L2(distributed cache), we can’t unwrap it directly and can only retrieve the value through its API
221+ return await HybridCache . GetOrCreateAsync (
222+ key : NormalizeKey ( key ) ,
223+ factory : async cancel => await factory ( ) ,
224+ options : optionsFactory ? . Invoke ( ) ,
225+ tags : null ,
226+ cancellationToken : token ) ;
222227 }
223228
224229 value = await factory ( ) ;
0 commit comments