Skip to content

Commit

Permalink
Added Redis key removal after db update
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytrotsko committed Jul 31, 2023
1 parent c023a13 commit 9957a3f
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/maintenance/update_last_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ def main():
today_date = dtime.today().date()
for key in redis_keys:
api_key, last_time_used = str(key).split("/")[1], dtime.strptime(str(redis_cli.get(key)), "%Y-%m-%d").date()
if last_time_used < today_date:
redis_cli.delete(key)
continue
cur.execute(
f"""
UPDATE
Expand All @@ -31,6 +28,7 @@ def main():
WHERE api_key = "{api_key}" AND (last_time_used < "{last_time_used}" OR last_time_used IS NULL)
"""
)
redis_cli.delete(key)
cur.close()
cnx.commit()
cnx.close()
Expand Down

0 comments on commit 9957a3f

Please sign in to comment.