tryAcquire

fun STM.tryAcquire(maxRequests: Int, nowMs: Long): Boolean(source)

Attempts to acquire a request slot within an STM transaction. Cleans up expired entries and checks against maxRequests.

Return

true if the request was allowed, false if rate limited

Parameters

maxRequests

the maximum number of requests allowed in the window

nowMs

the current time in milliseconds