class_docstr: Class that implements LRU cache with expiring items.
  
  LRU caches remove items in a FIFO manner, such that the oldest
  items to be used are the first to be removed.
  If you attempt to retrieve a cache item that is older than the
  expiration time, the item will be invalidated.
class_docstr_tok: ["Class","that","implements","LRU","cache","with","expiring","items",".","LRU","caches","remove","items","in","a","FIFO","manner",",","such","that","the","oldest","items","to","be","used","are","the","first","to","be","removed",".","If","you","attempt","to","retrieve","a","cache","item","that","is","older","than","the","expiration","time",",","the","item","will","be","invalidated","."]
docstr: Initialize an ``LRUCache`` instance.
  
  Args:
      max_cache_items (int): Maximum number of items to store in cache.
      expiration_horizon (datetime.timedelta): Maximum time duration a cache element can
          persist before being invalidated.
      retrieval_function (Callable[[KeyType, ValType], ValType]): Function which maps cache
          keys and current values to new values. This function must have kwarg arguments
          ``key`` and ``value``. This function is called as a fallback when the key
          is not found in the cache, or a key has expired.
docstr_tok: ["Initialize","an","``","LRUCache","``","instance",".","Args",":","max_cache_items","(","int",")",":","Maximum","number","of","items","to","store","in","cache",".","expiration_horizon","(","datetime.timedelta",")",":","Maximum","time","duration","a","cache","element","can","persist","before","being","invalidated",".","retrieval_function","(","Callable","[","[","KeyType",",","ValType","]",",","ValType","]",")",":","Function","which","maps","cache","keys","and","current","values","to","new","values",".","This","function","must","have","kwarg","arguments","``","key","``","and","``","value","``",".","This","function","is","called","as","a","fallback","when","the","key","is","not","found","in","the","cache",",","or","a","key","has","expired","."]
code: def __init__(
      self,
      max_cache_items: int,
      expiration_horizon: datetime.timedelta,
      retrieval_function: Callable[[KeyType, ValType], ValType],
  ) -> None:
      """Initialize an ``LRUCache`` instance.
  
      Args:
          max_cache_items (int): Maximum number of items to store in cache.
          expiration_horizon (datetime.timedelta): Maximum time duration a cache element can
              persist before being invalidated.
          retrieval_function (Callable[[KeyType, ValType], ValType]): Function which maps cache
              keys and current values to new values. This function must have kwarg arguments
              ``key`` and ``value``. This function is called as a fallback when the key
              is not found in the cache, or a key has expired.
  
      """
      self._max_cache_items = max_cache_items
      self._lru_cache: collections.OrderedDict = (
          collections.OrderedDict()
      )
      self._expiration_horizon = expiration_horizon
      self._retrieval_function = retrieval_function
  
file_path: sagemaker-python-sdk/src/sagemaker/utilities/cache.py
imports: from __future__ import absolute_import
  import datetime
  import collections
  from typing import Tuple, TypeVar, Generic, Callable, Optional
label_desc: Use image node_id 1 to create a new LRUCache object from inherited base classes: Generic with example: obj = LRUCache(max_cache_items, expiration_horizon, retrieval_function)