class_docstr: Manages all ResourceCache instances
docstr: Return the mem cache for the given key.
  
  If it doesn't exist, create a new one with the given params.
docstr_tok: ["Return","the","mem","cache","for","the","given","key",".","If","it","does","n't","exist",",","create","a","new","one","with","the","given","params","."]
code: def get_cache(
      self,
      key: str,
      display_name: str,
      max_entries: int | float | None,
      ttl: float | timedelta | str | None,
      validate: ValidateFunc | None,
      allow_widgets: bool,
  ) -> ResourceCache:
      """Return the mem cache for the given key.
  
      If it doesn't exist, create a new one with the given params.
      """
      if max_entries is None:
          max_entries = math.inf
  
      ttl_seconds = ttl_to_seconds(ttl)
  
      # Get the existing cache, if it exists, and validate that its params
      # haven't changed.
      with self._caches_lock:
          cache = self._function_caches.get(key)
          if (
              cache is not None
              and cache.ttl_seconds == ttl_seconds
              and cache.max_entries == max_entries
              and _equal_validate_funcs(cache.validate, validate)
          ):
              return cache
  
          # Create a new cache object and put it in our dict
          _LOGGER.debug("Creating new ResourceCache (key=%s)", key)
          cache = ResourceCache(
              key=key,
              display_name=display_name,
              max_entries=max_entries,
              ttl_seconds=ttl_seconds,
              validate=validate,
              allow_widgets=allow_widgets,
          )
          self._function_caches[key] = cache
          return cache
  
imports: from __future__ import annotations
  import math
  import threading
  import types
  from datetime import timedelta
  from typing import Any, Callable, TypeVar, cast, overload
  from cachetools import TTLCache
  from typing_extensions import TypeAlias
  import streamlit
  from streamlit.deprecation_util import show_deprecation_warning
  from streamlit.logger import get_logger
  from streamlit.runtime.caching import cache_utils
  from streamlit.runtime.caching.cache_errors import CacheKeyNotFoundError
  from streamlit.runtime.caching.cache_type import CacheType
  from streamlit.runtime.caching.cache_utils import Cache, CachedFuncInfo, make_cached_func_wrapper, ttl_to_seconds
  from streamlit.runtime.caching.cached_message_replay import CachedMessageReplayContext, CachedResult, ElementMsgData, MsgData, MultiCacheResults
  from streamlit.runtime.caching.hashing import HashFuncsDict
  from streamlit.runtime.metrics_util import gather_metrics
  from streamlit.runtime.scriptrunner.script_run_context import get_script_run_ctx
  from streamlit.runtime.stats import CacheStat, CacheStatsProvider, group_stats
  from streamlit.vendor.pympler.asizeof import asizeof
label_desc: Use image node_id 2 for calling the ResourceCaches obj's underlying member method code with example usage: obj.get_cache(key, display_name, max_entries, ttl, validate, allow_widgets) and returns: cache, cache