Skip to content

Commit e878077

Browse files
committed
Use JSON source generator & enable trimming
- This is based on work in PR #304
1 parent b6102f0 commit e878077

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Src/Fido2.AspNet/DistributedCacheMetadataService.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using Microsoft.Extensions.Internal;
66
using Microsoft.Extensions.Logging;
77

8+
using Fido2NetLib.Serialization;
9+
810
namespace Fido2NetLib;
911

1012
public class DistributedCacheMetadataService : IMetadataService
@@ -103,7 +105,7 @@ protected virtual async Task StoreDistributedCachedBlob(IMetadataRepository repo
103105
{
104106
await _distributedCache.SetStringAsync(
105107
GetBlobCacheKey(repository),
106-
JsonSerializer.Serialize(payload),
108+
JsonSerializer.Serialize(payload, FidoModelSerializerContext.Default.MetadataBLOBPayload),
107109
new DistributedCacheEntryOptions()
108110
{
109111
AbsoluteExpiration = GetDistributedCacheAbsoluteExpiryTime(GetNextUpdateTimeFromPayload(payload))
@@ -120,7 +122,7 @@ protected virtual async Task<MetadataBLOBPayload> GetDistributedCachedBlob(IMeta
120122
{
121123
try
122124
{
123-
var cachedBlob = JsonSerializer.Deserialize<MetadataBLOBPayload>(distributedCacheEntry);
125+
var cachedBlob = JsonSerializer.Deserialize(distributedCacheEntry, FidoModelSerializerContext.Default.MetadataBLOBPayload);
124126
var nextUpdateTime = GetNextUpdateTimeFromPayload(cachedBlob);
125127

126128
//If the cache until time is in the past then update and return new data, otherwise return the cached value

0 commit comments

Comments
 (0)