public async Task <SawmillGeocodeRequest> LookupAsync(string value) { var location = locationCreator.Create(value); if (location.Status != SawmillStatus.RequiresLookup) { return(location); // Failed to validate as worth looking up. } // Is this value already in our L1 local (memory) cache? var cachedLocation = await level1Cache.FindByKeyAsync(location.SourceKey); if (cachedLocation != null) { logger?.LogDebug((int)LogEventIds.L1CacheManagerHit, "L1 hit: '{value}'", value); return(cachedLocation); } logger?.LogInformation((int)LogEventIds.L1CacheManagerMiss, "Cache miss: '{value}'", value); // No, is it in our L2 cheap storage db? cachedLocation = await level2Cache.FindByKeyAsync(location.SourceKey); if (cachedLocation != null) { logger?.LogDebug((int)LogEventIds.L2CacheManagerHit, "L2 hit: '{value}'", value); return(cachedLocation); } logger?.LogInformation((int)LogEventIds.L2CacheManagerMiss, "Cache miss: '{value}'", value); location.Status = SawmillStatus.RequiresGeocoding; // Cache this location in L1 (local) so we don't keep checking L2 (remote) if the same key comes up again. await level1Cache.InsertAsync(location); return(location); }