code: def test_response_cache_cleanup():
      """
      Checks that the response cache replaces old entries for a given thread
      with new entries as they come in, instead of creating new entries
      (possibly wasting memory on unneeded entries)
      """
      # Check that the response cache cleans up previous entries for a given
      # thread properly.
      cache = ResponseCache()
      cache.check_cache(16, 123)
      cache.update_cache(16, 123, "Some response")
      assert len(cache.cache) == 1
  
      cache.check_cache(16, 124)
      cache.update_cache(16, 124, "Second response")
      assert len(cache.cache) == 1  # Should reuse entry for thread 16
      assert cache.check_cache(16, 124) == "Second response"
  
file_path: ray/python/ray/tests/test_response_cache.py
imports: from ray.util.client.common import _id_is_newer, ResponseCache, OrderedResponseCache, INT32_MAX
  import threading
  import time
  import pytest
label_desc: Use image node_id 9 for calling a global function with example usage: test_response_cache_cleanup() without return types