CL.THROTTLE
Syntax
CL.THROTTLE <key> <max_burst> <count per period> <period> [<quantity>]
Time complexity: O(1)
This command provides functionality for implementing a rate limit mechanism and is based on the Redis module called redis-cell.
Return
An array of 5 integers with the following values:
- Whether to limit the related action (0 for allowed, 1 for limited).
- The total limit of the key. (Equivalent to
X-RateLimit-Limit
) - The remaining limit of the key. (Equivalent to
X-RateLimit-Remaining
) - Number of seconds to wait until a retry if the related action should be limited, else -1. (Equivalent to
Retry-After
) - Number of seconds until the limit is fully restored. (Equivalent to
X-RateLimit-Reset
)
Examples
dragonfly> CL.THROTTLE USER1 0 1 10 1
1) (integer) 0
2) (integer) 1
3) (integer) 0
4) (integer) -1
5) (integer) 11
dragonfly> CL.THROTTLE USER1 0 1 10 1
1) (integer) 1
2) (integer) 1
3) (integer) 0
4) (integer) 10
5) (integer) 10