@@ -189,13 +189,13 @@ class QueryCache:
189189
190190 def __init__ (self , cache : DICOMObjectCache ):
191191 self .cache = cache
192- self .queries : Dict [Query , Tuple [DICOMObjectReference , ...]] = {}
192+ self .queries : Dict [str , Tuple [DICOMObjectReference , ...]] = {}
193193
194194 def add_response (self , query : Query , response : Sequence [DICOMObject ]):
195195 """Cache response for this query"""
196196 self .cache .add_all (response )
197197 references = tuple (x .reference () for x in response )
198- self .queries [query .json ()] = references
198+ self .queries [query .model_dump_json ()] = references
199199
200200 def get_response (self , query : Query ) -> List [Study ]:
201201 """Obtain cached response for this query
@@ -206,7 +206,7 @@ def get_response(self, query: Query) -> List[Study]:
206206 If any of the results of query are not in cache or have expired
207207 """
208208 try :
209- references = self .queries [query .json ()]
209+ references = self .queries [query .model_dump_json ()]
210210 except KeyError as e :
211211 raise NodeNotFound (
212212 f"Query { query .to_short_string ()} not found in cache"
@@ -221,7 +221,7 @@ def get_response(self, query: Query) -> List[Study]:
221221 return retrieved
222222 except NodeNotFound as e :
223223 # This query response is not (fully) cached anymore. Remove
224- self .queries .pop (query .json ())
224+ self .queries .pop (query .model_dump_json ())
225225 raise NodeNotFound (
226226 f"One or more response to { query .to_short_string ()} "
227227 f"was not in cache"
0 commit comments