We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e5b21aa commit b4db7cdCopy full SHA for b4db7cd
Sources/App/Core/RateCatcherMiddleware.swift
@@ -26,10 +26,12 @@ final class RateCatcherMiddleware: AsyncMiddleware {
26
let seconds: Int = Int(Date().timeIntervalSince1970)
27
let combinedKey: RedisKey = "\(cfray):\(seconds)"
28
29
- let countOverWindow: Int = try await request.redis.increment(combinedKey)
+ var countOverWindow: Int = try await request.redis.increment(combinedKey).get()
30
for i in seconds - windowSize ..< seconds {
31
let key: RedisKey = "\(cfray):\(i)"
32
- countOverWindow += try await request.redis.get(key, as: Int.self)
+ if let value = try await request.redis.get(key, as: Int.self).get() {
33
+ countOverWindow += value
34
+ }
35
}
36
37
if countOverWindow > 999 {
0 commit comments