From 218077725dab8fddb069012d1a4cc58e140442c6 Mon Sep 17 00:00:00 2001 From: abdulhade Date: Wed, 26 Feb 2025 04:36:48 +0300 Subject: [PATCH] Added cursors/push-ttl endpoint. --- app/cursors.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/cursors.py b/app/cursors.py index c188aa8..424c425 100644 --- a/app/cursors.py +++ b/app/cursors.py @@ -76,3 +76,18 @@ async def close_cursor(cursor_id: str) -> None: await cached_cursor.close() del mysql.cached_cursors[cursor_id] + + +@router.post( + "push-ttl/{cursor_id}", + dependencies=[Depends(get_current_user)], + status_code=status.HTTP_200_OK, +) +async def cursor_push_ttl(cursor_id: str, new_ttl: int|None=None) -> CachedCursorOut: + cached_cursor = mysql.cached_cursors.get(cursor_id, None) + if cached_cursor is None: + raise CursorNotFound + cached_cursor.ttl = new_ttl if new_ttl else cached_cursor.ttl + cached_cursor.close_at = cached_cursor.upgrade_close_at() + return cached_cursor +