@@ -375,3 +375,29 @@ def register_default_datapacks(self):
375375 self .register_datapack (data .Data_17326 , lambda r : 17326 <= r .build < 18317 )
376376 self .register_datapack (data .Data_18317 , lambda r : 18317 <= r .build < 19595 )
377377 self .register_datapack (data .Data_19595 , lambda r : 19595 <= r .build )
378+
379+ class SC2Cache (SC2Factory ):
380+
381+ def __init__ (self , ** options ):
382+ super (SC2Cache , self ).__init__ (self , ** options )
383+ self .cache = IntitializeCache (** options )
384+
385+ def load_map (self , map_file , options = None , ** new_options ):
386+ options = options or utils .merged_dict (self .options , new_options )
387+
388+ if self .cache .has (map_file ):
389+ return self .cache .get (map_file )
390+ else :
391+ map = super (SC2Cache , self ).load_map (map_file , options = options )
392+ self .cache .set (map_file , map )
393+ return map
394+
395+ def load_replay (self , replay_file , options = None , ** new_options ):
396+ options = options or utils .merged_dict (self .options , new_options )
397+
398+ if self .cache .has (replay_file ):
399+ return self .cache .get (replay_file )
400+ else :
401+ replay = super (SC2Cache , self ).load_replay (replay_file , options = options )
402+ self .cache .set (replay_file , replay )
403+ return replay
0 commit comments