Skip to content

Commit

Permalink
cloud_functions: totals cache should be overwritten for skipDates (wo…
Browse files Browse the repository at this point in the history
  • Loading branch information
kev1n-peters authored May 3, 2022
1 parent ec87530 commit 3023b4a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions event_database/cloud_functions/totals.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 3023b4a

Please sign in to comment.