def incr_ratelimit(user, domain='all'):
 (list_key, set_key, _) = redis_key(user, domain)
 now = time.time()
 if (len(rules) == 0):
  return
 with client.pipeline() as pipe:
  count = 0
  while True:
   try:
    pipe.watch(list_key)
    last_val = pipe.lindex(list_key, (max_api_calls(user) - 1))
    pipe.multi()
    pipe.lpush(list_key, now)
    pipe.ltrim(list_key, 0, (max_api_calls(user) - 1))
    pipe.zadd(set_key, now, now)
    if (last_val is not None):
     pipe.zrem(set_key, last_val)
    api_window = max_api_window(user)
    pipe.expire(list_key, api_window)
    pipe.expire(set_key, api_window)
    pipe.execute()
    break
   except redis.WatchError:
    if (count > 10):
     logging.error('Failed to complete incr_ratelimit transaction without interference 10 times in a row! Aborting rate-limit increment')
     break
    count += 1
    continue

def incr_ratelimit ( user , domain = 'all' ) : ( list_key , set_key , _ ) = redis_key ( user , domain ) now = time . time ( ) if ( len ( rules ) == 0 ) : return with client . pipeline ( ) as pipe : count = 0 while True : try : pipe . watch ( list_key ) last_val = pipe . lindex ( list_key , ( max_api_calls ( user ) - 1 ) ) pipe . multi ( ) pipe . lpush ( list_key , now ) pipe . ltrim ( list_key , 0 , ( max_api_calls ( user ) - 1 ) ) pipe . zadd ( set_key , now , now ) if ( last_val is not None ) : pipe . zrem ( set_key , last_val ) api_window = max_api_window ( user ) pipe . expire ( list_key , api_window ) pipe . expire ( set_key , api_window ) pipe . execute ( ) break except redis . WatchError : if ( count > 10 ) : logging . error ( 'Failed to complete incr_ratelimit transaction without interference 10 times in a row! Aborting rate-limit increment' ) break count += 1 continue
increases the rate-limit for the specified user .