Skip to content

Commit 93ca008

Browse files
committedFeb 10, 2025
Use JSON source generator & enable trimming
- This is based on work in PR #304
1 parent b6102f0 commit 93ca008

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
@@ -1,5 +1,7 @@
11
using System.Text.Json;
22

3+
using Fido2NetLib.Serialization;
4+
35
using Microsoft.Extensions.Caching.Distributed;
46
using Microsoft.Extensions.Caching.Memory;
57
using Microsoft.Extensions.Internal;
@@ -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)
Failed to load comments.