class documentation

A simple cache implementation, that only requires `.get_cache_key()` to be overridden. The rate (requests / seconds) is set by a `rate` attribute on the Throttle class. The attribute is a string of the form 'number_of_requests/period'. Period should be one of: ('s', 'sec', 'm', 'min', 'h', 'hour', 'd', 'day') Previous request information used for throttling is stored in the cache.

Method __init__ Undocumented
Method allow_request Implement the check to see if the request should be throttled.
Method get_cache_key Should return a unique cache-key which can be used for throttling. Must be overridden.
Method get_rate Determine the string representation of the allowed request rate.
Method parse_rate Given the request rate string, return a two tuple of: <allowed number of requests>, <period of time in seconds>
Method throttle_failure Called when a request to the API has failed due to throttling.
Method throttle_success Inserts the current request's timestamp along with the key into the cache.
Method wait Returns the recommended next request time in seconds.
Class Variable cache_format Undocumented
Class Variable scope Undocumented
Instance Variable duration Undocumented
Instance Variable history Undocumented
Instance Variable key Undocumented
Instance Variable now Undocumented
Instance Variable num_requests Undocumented
Instance Variable rate Undocumented

Inherited from BaseThrottle:

Method get_ident Identify the machine making the request by parsing HTTP_X_FORWARDED_FOR if present and number of proxies is > 0. If not use all of HTTP_X_FORWARDED_FOR if it is available, if not use REMOTE_ADDR.
def __init__(self): (source)
def allow_request(self, request, view): (source)

Implement the check to see if the request should be throttled. On success calls `throttle_success`. On failure calls `throttle_failure`.

def get_cache_key(self, request, view): (source)

Should return a unique cache-key which can be used for throttling. Must be overridden. May return `None` if the request should not be throttled.

def get_rate(self): (source)

Determine the string representation of the allowed request rate.

def parse_rate(self, rate): (source)

Given the request rate string, return a two tuple of: <allowed number of requests>, <period of time in seconds>

def throttle_failure(self): (source)

Called when a request to the API has failed due to throttling.

def throttle_success(self): (source)

Inserts the current request's timestamp along with the key into the cache.

def wait(self): (source)

Returns the recommended next request time in seconds.

cache_format: str = (source)

Undocumented

Undocumented

Undocumented

Undocumented

num_requests = (source)