code: def test_cache_removes_old_items_once_size_limit_reached():
      my_cache = cache.LRUCache[int, Union[int, str]](
          max_cache_items=5,
          expiration_horizon=datetime.timedelta(hours=1),
          retrieval_function=retrieval_function,
      )
  
      for i in [1, 2, 3, 4, 5]:
          my_cache.put(i)
  
      assert len(my_cache) == 5
  
      my_cache.put(6)
      assert len(my_cache) == 5
      with pytest.raises(KeyError):
          my_cache.get(1, False)
      assert my_cache.get(2, False) == (retrieval_function(key=2), True)
  
file_path: sagemaker-python-sdk/tests/unit/sagemaker/utilities/test_cache.py
imports: from __future__ import absolute_import
  from typing import Optional, Union
  from mock.mock import MagicMock, patch
  import pytest
  from sagemaker.utilities import cache
  import datetime
label_desc: Use image node_id 5 for calling a global function with example usage: test_cache_removes_old_items_once_size_limit_reached() without return types