v2 (WPF)
This commit is contained in:
18
LeagueAPI/CachingHttpClient.cs
Normal file
18
LeagueAPI/CachingHttpClient.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace LeagueAPI;
|
||||
|
||||
public class HttpCache : Dictionary<string, string> { }
|
||||
|
||||
public static class CachingHttpClient
|
||||
{
|
||||
private static HttpCache _cache = ResourceService.GetHttpCache() ?? [];
|
||||
private static HttpClient _client = new();
|
||||
|
||||
public static async Task<string> GetStringAsync(string requestUri)
|
||||
{
|
||||
if (_cache.TryGetValue(requestUri, out string? response))
|
||||
{
|
||||
return response;
|
||||
}
|
||||
return await _client.GetStringAsync(requestUri);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user