Ë
    úmxiÉ  ã                  óØ   — d Z ddlmZ ddlmZ ddlmZmZmZ ddl	m
Z
 ddlmZ ddlmZ erddlmZ  ed	ed
ef   ¬«      Z ed«      	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       Zy)zA library of caching utilities.é    )Úannotations)ÚCallable)ÚTYPE_CHECKINGÚAnyÚTypeVar)Údeprecation_util)ÚCACHE_DOCS_URL)Úgather_metrics)ÚHashFuncsDictÚF.)ÚboundÚcacheNc                ó¢   — ddl }t        j                  dt        › d�«       |r|j	                  | ||||¬«      S |j                  | |||||¬«      S )aÀ  Legacy caching decorator (deprecated).

    Legacy caching with ``st.cache`` has been removed from Streamlit. This is
    now an alias for ``st.cache_data`` and ``st.cache_resource``.

    Parameters
    ----------
    func : callable
        The function to cache. Streamlit hashes the function's source code.

    persist : bool
        Whether to persist the cache on disk.

    allow_output_mutation : bool
        Whether to use ``st.cache_data`` or ``st.cache_resource``. If this is
        ``False`` (default), the arguments are passed to ``st.cache_data``. If
        this is ``True``, the arguments are passed to ``st.cache_resource``.

    show_spinner : bool
        Enable the spinner. Default is ``True`` to show a spinner when there is
        a "cache miss" and the cached data is being created.

    suppress_st_warning : bool
        This is not used.

    hash_funcs : dict or None
        Mapping of types or fully qualified names to hash functions. This is used to
        override the behavior of the hasher inside Streamlit's caching mechanism: when
        the hasher encounters an object, it will first check to see if its type matches
        a key in this dict and, if so, will use the provided function to generate a hash
        for it. See below for an example of how this can be used.

    max_entries : int or None
        The maximum number of entries to keep in the cache, or ``None``
        for an unbounded cache. (When a new entry is added to a full cache,
        the oldest cached entry will be removed.) The default is ``None``.

    ttl : float or None
        The maximum number of seconds to keep an entry in the cache, or
        None if cache entries should not expire. The default is None.

    Example
    -------
    >>> import streamlit as st
    >>>
    >>> @st.cache
    ... def fetch_and_clean_data(url):
    ...     # Fetch data from URL here, and then clean it up.
    ...     return data
    >>>
    >>> d1 = fetch_and_clean_data(DATA_URL_1)
    >>> # Actually executes the function, since this is the first time it was
    >>> # encountered.
    >>>
    >>> d2 = fetch_and_clean_data(DATA_URL_1)
    >>> # Does not execute the function. Instead, returns its previously computed
    >>> # value. This means that now the data in d1 is the same as in d2.
    >>>
    >>> d3 = fetch_and_clean_data(DATA_URL_2)
    >>> # This is a different URL, so the function executes.

    To set the ``persist`` parameter, use this command as follows:

    >>> @st.cache(persist=True)
    ... def fetch_and_clean_data(url):
    ...     # Fetch data from URL here, and then clean it up.
    ...     return data

    To disable hashing return values, set the ``allow_output_mutation`` parameter to
    ``True``:

    >>> @st.cache(allow_output_mutation=True)
    ... def fetch_and_clean_data(url):
    ...     # Fetch data from URL here, and then clean it up.
    ...     return data


    To override the default hashing behavior, pass a custom hash function.
    You can do that by mapping a type (e.g. ``MongoClient``) to a hash function (``id``)
    like this:

    >>> @st.cache(hash_funcs={MongoClient: id})
    ... def connect_to_database(url):
    ...     return MongoClient(url)

    Alternatively, you can map the type's fully-qualified name
    (e.g. ``"pymongo.mongo_client.MongoClient"``) to the hash function instead:

    >>> @st.cache(hash_funcs={"pymongo.mongo_client.MongoClient": id})
    ... def connect_to_database(url):
    ...     return MongoClient(url)

    r   Nz¯
`st.cache` is deprecated and will be removed soon. Please use one of Streamlit's new
caching commands, `st.cache_data` or `st.cache_resource`. More information
[in our docs](zà).

**Note**: The behavior of `st.cache` was updated in Streamlit 1.36 to the new caching
logic used by `st.cache_data` and `st.cache_resource`. This might lead to some problems
or unexpected behavior in certain edge cases.
)Úshow_spinnerÚ
hash_funcsÚmax_entriesÚttl)Úpersistr   r   r   r   )Ú	streamlitr   Úshow_deprecation_warningr	   Úcache_resourceÚ
cache_data)	Úfuncr   Úallow_output_mutationr   Úsuppress_st_warningr   r   r   Ústs	            úa/home/htdocs/ttos/venv/lib/python3.12/site-packages/streamlit/runtime/caching/legacy_cache_api.pyr   r   "   sƒ   € óP ä×-Ñ-ðô Ðð ð	ô
ñ Ø× Ñ ØØ%Ø!Ø#Øð !ó 
ð 	
ð �=‰=ØØØ!ØØØð ó ð ó    )NFFTFNNN)r   zF | Noner   Úboolr   r   r   r   r   r   r   zHashFuncsDict | Noner   z
int | Noner   zfloat | NoneÚreturnr   )Ú__doc__Ú
__future__r   Úcollections.abcr   Útypingr   r   r   r   r   Ústreamlit.runtime.cachingr	   Ústreamlit.runtime.metrics_utilr
   Ú!streamlit.runtime.caching.hashingr   r   r   © r   r   ú<module>r)      sÎ   ðñ &å "å $ß .Ñ .å &Ý 4Ý 9áÝ?ñ ˆC�x  S Ñ)Ô*€ñ �ÓàØØ"'ØØ %Ø'+Ø"ØðGØ
ðGàðGð  ðGð ð	Gð
 ðGð %ðGð ðGð 
ðGð òGó ñGr   