core.ratelimit
¶
Module Contents¶
Classes¶
This class is used to restrict access to certain functions to maxRate calls per minute. |
Functions¶
|
- class core.ratelimit.RateLimit(resource, maxRate, minutes, method)¶
Bases:
object
This class is used to restrict access to certain functions to maxRate calls per minute.
Usage: Create an instance of this object in you modules __init__ function. then call isQuotaAvailable before executing the action to check if there is quota available and after executing the action decrementQuota.
- rateLimitKind = viur-ratelimit¶
- _getEndpointKey(self)¶
- Warning
It’s invalid to call _getEndpointKey if method is set to user and there’s no user logged in!
- Returns
the key associated with the current endpoint (it’s IP or the key of the current user)
- _getCurrentTimeKey(self)¶
- Returns
the current lockperiod used in second position of the memcache key
- decrementQuota(self)¶
Removes one attempt from the pool of available Quota for that user/ip
- isQuotaAvailable(self)¶
Checks if there’s currently quota available for the current user/ip :return: True if there’s quota available, False otherwise :rtype: bool
- core.ratelimit.cleanOldRateLocks(*args, **kwargs)¶