From 09af56826327caafbf3181ce0bf39c1da7561239 Mon Sep 17 00:00:00 2001 From: Ivan Golikov Date: Thu, 26 Dec 2024 22:52:41 +0100 Subject: [PATCH] Atomic get and deletion of secret data --- pssecret/main.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pssecret/main.py b/pssecret/main.py index 0097e93..0e97ec3 100644 --- a/pssecret/main.py +++ b/pssecret/main.py @@ -24,13 +24,12 @@ async def set_secret(data: Secret): response_model=Secret, responses={404: {"description": "The item was not found"}}, ) -async def get_secret(secret_key): - data = await redis.get(secret_key) +async def get_secret(secret_key: str): + data: str | None = await redis.getdel(secret_key) if data is None: raise HTTPException(404) - await redis.delete(secret_key) return { "data": data, }