Skip to content

Commit 4ae329c

Browse files
committed
Set cfray keys to expire after one hour
1 parent e0aa3c6 commit 4ae329c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Sources/App/Core/BackpressureMiddleware.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ final class BackpressureMiddleware: AsyncMiddleware {
3737
request.logger.log(level: .warning, "BackpressureMiddleware failed to increment key '\(combinedKey)'.")
3838
return try await next.respond(to: request)
3939
}
40+
if countOverWindow == 1 {
41+
_ = try? await redis.expire(key: combinedKey, after: .seconds(3600))
42+
}
4043

4144
for i in epochSeconds - slidingWindow ..< epochSeconds {
4245
let key = "\(cfray):\(i)"

0 commit comments

Comments
 (0)