Add random caching

This commit is contained in:
2022-04-02 16:56:34 +03:00
parent f1f320da9b
commit 2f6a4a192a
7 changed files with 86 additions and 14 deletions

View File

@@ -28,9 +28,12 @@ async def get_sequences():
@sequence_router.get("/random", response_model=Sequence)
async def get_random_sequence(
request: Request,
allowed_langs: frozenset[str] = Depends(get_allowed_langs),
):
sequence_id = await GetRandomSequenceService.get_random_id(allowed_langs)
sequence_id = await GetRandomSequenceService.get_random_id(
allowed_langs, request.app.state.redis
)
return await SequenceDB.objects.get(id=sequence_id)