@@ -64,7 +64,7 @@ def __init__(self):
6464 self ._queue_by_db_by_root_path : dict [
6565 str , dict [str , queue .Queue [FastAPI ]]
6666 ] = defaultdict (lambda : defaultdict (queue .Queue ))
67- self .__cache_sequence = 0
67+ self .__cache_sequences = {}
6868 self ._lock = threading .Lock ()
6969
7070 def __get_pool (self , env : Environment , root_path : str ) -> queue .Queue [FastAPI ]:
@@ -102,25 +102,25 @@ def get_app(
102102 finally :
103103 self .__return_app (env , app , root_path )
104104
105- @ property
106- def cache_sequence ( self ) -> int :
107- return self .__cache_sequence
105+ def get_cache_sequence ( self , key : str ) -> int :
106+ with self . _lock :
107+ return self .__cache_sequences . get ( key , 0 )
108108
109- @cache_sequence .setter
110- def cache_sequence (self , value : int ) -> None :
111- if value != self .__cache_sequence :
112- with self ._lock :
113- self .__cache_sequence = value
109+ def set_cache_sequence (self , key : str , value : int ) -> None :
110+ with self ._lock :
111+ if key not in self .__cache_sequences or value != self .__cache_sequences [key ]:
112+ self .__cache_sequences [key ] = value
114113
115114 def _check_cache (self , env : Environment ) -> None :
116- cache_sequence = env .registry .cache_sequence
117- if cache_sequence != self .cache_sequence and self .cache_sequence != 0 :
118- _logger .info (
119- "Cache registry updated, reset fastapi_app pool for the current "
120- "database"
121- )
122- self .invalidate (env )
123- self .cache_sequence = cache_sequence
115+ cache_sequences = env .registry .cache_sequences
116+ for key , value in cache_sequences .items ():
117+ if value != self .get_cache_sequence (key ) and self .get_cache_sequence (key ) != 0 :
118+ _logger .info (
119+ "Cache registry updated, reset fastapi_app pool for the current "
120+ "database"
121+ )
122+ self .invalidate (env )
123+ self .set_cache_sequence (key , value )
124124
125125 def invalidate (self , env : Environment , root_path : str | None = None ) -> None :
126126 db_name = env .cr .dbname
0 commit comments