Skip to content

Commit cff2545

Browse files
authored
Merge pull request #22811 from abpframework/Microsoft.Extensions.Caching.Hybrid
Downgrade `MongoSandbox` to `1.0.1`.
2 parents ccf1501 + 6b0097a commit cff2545

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

Directory.Packages.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
<PackageVersion Include="EphemeralMongo6.runtime.linux-x64" Version="2.0.0" />
3939
<PackageVersion Include="EphemeralMongo6.runtime.osx-x64" Version="1.1.3" />
4040
<PackageVersion Include="EphemeralMongo6.runtime.win-x64" Version="2.0.0" />
41-
<PackageVersion Include="MongoSandbox.Core" Version="2.0.0" />
42-
<PackageVersion Include="MongoSandbox6.runtime.linux-x64" Version="2.0.0" />
41+
<PackageVersion Include="MongoSandbox.Core" Version="1.0.1" />
42+
<PackageVersion Include="MongoSandbox6.runtime.linux-x64" Version="1.0.1" />
4343
<PackageVersion Include="MongoSandbox6.runtime.osx-x64" Version="1.0.1" />
44-
<PackageVersion Include="MongoSandbox6.runtime.win-x64" Version="2.0.0" />
44+
<PackageVersion Include="MongoSandbox6.runtime.win-x64" Version="1.0.1" />
4545
<PackageVersion Include="FluentValidation" Version="11.11.0" />
4646
<PackageVersion Include="Google.Cloud.Storage.V1" Version="4.13.0" />
4747
<PackageVersion Include="Hangfire.AspNetCore" Version="1.8.18" />

framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpCachingModule.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using Microsoft.Extensions.DependencyInjection;
22
using System;
3-
using Microsoft.Extensions.Caching.Hybrid;
4-
using Microsoft.Extensions.DependencyInjection.Extensions;
53
using Volo.Abp.Caching.Hybrid;
64
using Volo.Abp.Json;
75
using Volo.Abp.Modularity;

framework/src/Volo.Abp.Caching/Volo/Abp/Caching/Hybrid/AbpHybridCache.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)