Skip to content

Commit

Permalink
documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
syamsudotdev committed May 31, 2024
1 parent 25f629c commit 0a5e48b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/probe/prober/http/response-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ function ensureCacheSize() {
// this will delete already expired cache entries
function ensureCacheTtl() {
const now = Date.now()
// iterate over cache entries
// since we use map, the order of entries are based on insertion order
for (const [key, { expireAt }] of responseCache.entries()) {
if (expireAt <= now) {
responseCache.delete(key)
} else {
// next items have valid time-to-live
// break out of loop to save time
// iteration is not necessary anymore
break
}
}
Expand Down

0 comments on commit 0a5e48b

Please sign in to comment.