cloud_functions: totals cache should be overwritten for skipDates (#1147)

This commit is contained in:
kev1n-peters 2022-05-03 15:40:56 -05:00 committed by GitHub
parent ec87530bac
commit 3023b4a375
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -153,14 +153,15 @@ func createCountsOfInterval(tbl *bigtable.Table, ctx context.Context, prefix str
results[dateStr][countBy] = results[dateStr][countBy] + 1
}
if cacheData, ok := warmTotalsCache[dateStr][cachePrefix]; !ok || len(cacheData) <= 1 {
// set the result in the cache
if daysAgo >= 1 {
muWarmTotalsCache.Lock()
warmTotalsCache[dateStr][cachePrefix] = results[dateStr]
if cacheData, ok := warmTotalsCache[dateStr][cachePrefix]; !ok || len(cacheData) <= 1 || !useCache(dateStr) {
// set the result in the cache
warmTotalsCache[dateStr][cachePrefix] = results[dateStr]
cacheNeedsUpdate = true
}
muWarmTotalsCache.Unlock()
cacheNeedsUpdate = true
}
}(tbl, ctx, prefix, daysAgo)
}