Atomic get and deletion of secret data
This commit is contained in:
parent
ea846936c4
commit
09af568263
1 changed files with 2 additions and 3 deletions
|
@ -24,13 +24,12 @@ async def set_secret(data: Secret):
|
||||||
response_model=Secret,
|
response_model=Secret,
|
||||||
responses={404: {"description": "The item was not found"}},
|
responses={404: {"description": "The item was not found"}},
|
||||||
)
|
)
|
||||||
async def get_secret(secret_key):
|
async def get_secret(secret_key: str):
|
||||||
data = await redis.get(secret_key)
|
data: str | None = await redis.getdel(secret_key)
|
||||||
|
|
||||||
if data is None:
|
if data is None:
|
||||||
raise HTTPException(404)
|
raise HTTPException(404)
|
||||||
|
|
||||||
await redis.delete(secret_key)
|
|
||||||
return {
|
return {
|
||||||
"data": data,
|
"data": data,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue