code: def dump_cache():
      """
      Marks cache for writing to disk. 5 seconds after no one else flags the cache for writing, it is written.
      """
  
      global dump_cache_after
      global dump_cache_thread
  
      def thread_func():
          global dump_cache_after
          global dump_cache_thread
  
          while (
              dump_cache_after is not None
              and time.time() < dump_cache_after
          ):
              time.sleep(1)
  
          with cache_lock:
              cache_filename_tmp = cache_filename + "-"
              with open(
                  cache_filename_tmp, "w", encoding="utf8"
              ) as file:
                  json.dump(
                      cache_data, file, indent=4, ensure_ascii=False
                  )
  
              os.replace(cache_filename_tmp, cache_filename)
  
              dump_cache_after = None
              dump_cache_thread = None
  
      with cache_lock:
          dump_cache_after = time.time() + 5
          if dump_cache_thread is None:
              dump_cache_thread = threading.Thread(
                  name="cache-writer", target=thread_func
              )
              dump_cache_thread.start()
  
file_path: stable-diffusion-webui/modules/cache.py
imports: import json
  import os
  import os.path
  import threading
  import time
  from modules.paths import data_path, script_path
label_desc: Use image node_id 1 for calling a global function with example usage: dump_cache() without return types