Whether save and load functions are configured for persistence.
Get a snapshot of current statistics and state.
Object containing usage statistics and current state
Get the current state for persistence. This is the minimal data structure needed to restore the bucket.
Load state from the configured load function. If the load function returns undefined/null, the bucket state is not modified.
Save the current state using the configured save function.
Waits for tokens to be available and consumes them atomically.
Waits for the next token to be available before allowing the caller to proceed.
Token bucket implementation of rate limiting with optional persistence support.
Example
Example