def api_daily_incr(): current = redis_store.exists("api_daily") redis_store.incr("api_daily", amount=1) if not current: now = datetime.now() expire = now.replace(day=(now.day + 1), hour=0, minute=0, second=0, microsecond=0) redis_store.expireat("api_daily", expire)
def api_failure_incr(): current = redis_store.exists("api_failure") redis_store.incr("api_failure", amount=1) if not current: now = datetime.now() expire = now.replace(minute=(now.minute + (now.minute % 15)), second=0, microsecond=0) redis_store.expireat("api_failure", expire)