'Increases the (cached) request count by 1 for the given key and path.
If the request count exceeds its limit, raises RateLimitExceeded.
If the given key does not exist, each IP address (if given) gets
limit / time requests. Otherwise, a RateLimitForbidden is raised.'

def __call__(self, key, path='/', limit=None, time=None, ip=None, reset=100000):

    with self.lock:
        t = _time.time()
        p = ('/' + path.strip('/'))
        r = self.cache.get((key, p))
        if (reset and (reset < len(self.cache)) and (reset > self._n)):
            self.reset()
        if ((r is None) and (p != '/')):
            r = self.cache.get((key, '/'))
        if ((r is None) and (ip is not None) and (limit is not None) and (time is not None)):
            r = self.cache.setdefault((ip, p), (0, limit, time, t))
            key = ip
        if (r is None):
            raise RateLimitForbidden
        elif ((r[0] >= r[1]) and (r[2] > (t - r[3]))):
            raise RateLimitExceeded
        elif (r[0] >= r[1]):
            self.cache[(key, p)] = (1, r[1], r[2], t)
        elif (r[0] < r[1]):
            self.cache[(key, p)] = ((r[0] + 1), r[1], r[2], r[3])
