Atomic get and deletion of secret data

This commit is contained in:
Ivan Golikov 2024-12-26 22:52:41 +01:00
parent ea846936c4
commit 09af568263

View file

@ -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,
}