public static async Task <QueryBANResponse> RunAsync( QueryBANRequest request, GetCacheKey getCacheKey, GetCacheAsync getCache, SetCacheAsync setCache ) { if (request == null) { throw new ArgumentNullException(nameof(request)); } if (!request.IsValid) { throw new ArgumentException(nameof(request)); } string content = await getCache?.Invoke(getCacheKey?.Invoke(request)); if (string.IsNullOrEmpty(content)) { content = request.Coordinates == null ? await LookupAddressAsync(request.Address) : await LookupLocationAsync(request.Coordinates); await setCache?.Invoke(getCacheKey?.Invoke(request), content); } return(GetAddressInfos(content)); }
public static async Task <QueryBANResponse> RunAsync(QueryBANRequest request) { return(await RunAsync( request, GetLocalCacheKey, GetLocalCacheAsync, SetLocalCacheAsync )); }
public static string GetLocalCacheKey(QueryBANRequest request) => $"ban_{HashUtils.ToMD5(request.Coordinates?.ToString() ?? request.Address)}.json";