1616 TopIssue ,
1717)
1818
19+ METRICS_CACHE_TIMEOUT = 60 * 60 * 6 # 6 hours
20+
1921
2022def kcidb_execute_query (query , params = None ):
2123 try :
@@ -645,7 +647,13 @@ def get_issues_summary_data(*, checkout_ids: list[str]) -> list[dict]:
645647 return dict_fetchall (cursor = cursor )
646648
647649
648- def query_fetchone_work (* , cache_key : str , query : str , params : dict [str , Any ]):
650+ def query_fetchone_work (
651+ * ,
652+ cache_key : str ,
653+ query : str ,
654+ params : dict [str , Any ],
655+ timeout : int = METRICS_CACHE_TIMEOUT ,
656+ ):
649657 rows = get_query_cache (key = cache_key , params = params )
650658 if rows is not None :
651659 return rows
@@ -655,11 +663,17 @@ def query_fetchone_work(*, cache_key: str, query: str, params: dict[str, Any]):
655663 rows = cursor .fetchone ()
656664 finally :
657665 connections ["default" ].close ()
658- set_query_cache (key = cache_key , params = params , rows = rows )
666+ set_query_cache (key = cache_key , params = params , rows = rows , timeout = timeout )
659667 return rows
660668
661669
662- def query_fetchall_work (* , cache_key : str , query : str , params : dict [str , Any ]):
670+ def query_fetchall_work (
671+ * ,
672+ cache_key : str ,
673+ query : str ,
674+ params : dict [str , Any ],
675+ timeout : int = METRICS_CACHE_TIMEOUT ,
676+ ):
663677 rows = get_query_cache (key = cache_key , params = params )
664678 if rows is not None :
665679 return rows
@@ -669,7 +683,7 @@ def query_fetchall_work(*, cache_key: str, query: str, params: dict[str, Any]):
669683 rows = cursor .fetchall ()
670684 finally :
671685 connections ["default" ].close ()
672- set_query_cache (key = cache_key , params = params , rows = rows )
686+ set_query_cache (key = cache_key , params = params , rows = rows , timeout = timeout )
673687 return rows
674688
675689
0 commit comments