Skip to content

Commit

Permalink
fix: expire cached value after 30 seconds from accessing
Browse files Browse the repository at this point in the history
  • Loading branch information
moreal committed Oct 29, 2024
1 parent 6f567ed commit 2f4e8e4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Mimir.Worker/Client/HeadlessGQLClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using BitFaster.Caching;
using BitFaster.Caching.Lru;
using Libplanet.Crypto;
using Microsoft.IdentityModel.Tokens;
Expand All @@ -17,7 +18,13 @@ public class HeadlessGQLClient : IHeadlessGQLClient
private readonly Uri[] _urls;
private readonly string? _issuer;
private readonly string? _secret;
private readonly ConcurrentLru<long, GetTransactionsResponse> _transactionCache = new(10);

private readonly IAsyncCache<long, GetTransactionsResponse> _transactionCache =
new ConcurrentLruBuilder<long, GetTransactionsResponse>()
.AsAsyncCache()
.WithExpireAfterWrite(TimeSpan.FromSeconds(30))
.WithCapacity(10)
.Build();
private const int RetryAttempts = 3;
private const int DelayInSeconds = 5;

Expand Down

0 comments on commit 2f4e8e4

Please sign in to comment.