Skip to content

Commit

Permalink
cache fix
Browse files Browse the repository at this point in the history
  • Loading branch information
russbiggs committed Dec 14, 2024
1 parent b85a49a commit fecd568
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion openaq_api/openaq_api/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ async def check_api_key(
limited = True
requests_used = int(value)
ttl = await redis.ttl(key)

request.state.rate_limiter = (
f"{key}/{limit}/{requests_used}/{limit - requests_used}/{ttl}"
)
response.headers["x-ratelimit-limit"] = str(limit)
response.headers["x-ratelimit-remaining"] = str(requests_used)
response.headers["x-ratelimit-used"] = str(limit - requests_used)
Expand Down
2 changes: 1 addition & 1 deletion openaq_api/openaq_api/v3/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ async def get_register(
if redis_client:
async with redis_client.pipeline() as pipe:
await pipe.sadd("keys", user_token).hset(
user_token, mapping={"rate": 2000}
user_token, mapping={"rate": 60}
).execute()
return {"message": "success"}
except Exception as e:
Expand Down

0 comments on commit fecd568

Please sign in to comment.