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

def allow_request(self, request, view):

    if (self.rate is None):
        return True
    self.key = self.get_cache_key(request, view)
    if (self.key is None):
        return True
    self.history = self.cache.get(self.key, [])
    self.now = self.timer()
    while (self.history and (self.history[(-1)] <= (self.now - self.duration))):
        self.history.pop()
    if (len(self.history) >= self.num_requests):
        return self.throttle_failure()
    return self.throttle_success()
