Ë
    úmxi0  ã                   ó„   — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
  ed«      Z ed«      Z G d	„ d
eeef   «      Zy)zSLRU cache supporting TTL and max entry count, as well as release hooks for cleanup.é    )ÚCallable)ÚTypeVar)ÚTTLCache)Úoverride)Ú	OnReleaseÚKÚVc            
       ó¬   ‡ — e Zd ZdZdededeg ef   deddf
ˆ fd„Zede	e
ef   fˆ fd	„«       Zedd
edz  dee	e
ef      fˆ fd„«       Zde
ddfd„Zˆ xZS )ÚTTLCleanupCachea,  A TTLCache that supports hooks called when items are released.

    Note that item release only happens reliably when done automatically due to TTL
    or maxsize expiration - and specifically does not happen when using ``del``. To
    remove an item and have on_release be called, use safe_del.
    ÚmaxsizeÚttlÚtimerÚ
on_releaseÚreturnNc                 ó8   •— t         ‰| �  |||¬«       || _        y)a  Create a cache with the given size, TTL, and release hook.

        Parameters
        ----------
        maxsize : float
            The maximum number of elements this cache should hold.
        ttl : float
            The amount of time a cache entry should remain valid, in seconds.
        timer : Callable[[], float]
            The timer function to use to fetch the current time.
        on_release : OnRelease
            The function to call with cache entries when they are removed from the
            cache.
        )r   r   r   N)ÚsuperÚ__init__Ú_on_release)Úselfr   r   r   r   Ú	__class__s        €úb/home/htdocs/ttos/venv/lib/python3.12/site-packages/streamlit/runtime/caching/ttl_cleanup_cache.pyr   zTTLCleanupCache.__init__(   s!   ø€ ô* 	‰Ñ ¨c¸ÐÔ?Ø%ˆÕó    c                 óP   •— t         ‰| �  «       \  }}| j                  |«       ||fS ©N)r   Úpopitemr   )r   ÚkeyÚvaluer   s      €r   r   zTTLCleanupCache.popitem@   s+   ø€ ä‘W‘_Ó&‰
ˆˆUØ×Ñ˜ÔØ�EˆzÐr   Útimec                 ó\   •— t         ‰| �  |«      }|D ]  \  }}| j                  |«       Œ |S r   )r   Úexpirer   )r   r   ÚitemsÚ_r   r   s        €r   r    zTTLCleanupCache.expireF   s9   ø€ ä‘‘˜tÓ$ˆØò 	$‰HˆAˆuØ×Ñ˜UÕ#ð	$ð ˆr   r   c                 ó\   — || v }| j                  |«      }| |= |r| j                  |«       yy)zDelete that calls _on_release.N)Úgetr   )r   r   Ú	has_valueÚ	old_values       r   Úsafe_delzTTLCleanupCache.safe_delN   s5   € à˜4�Kˆ	Ø—H‘H˜S“Mˆ	Ø�ˆIáØ×Ñ˜YÕ'ð r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úfloatr   r   r   r   Útupler   r	   r   Úlistr    r'   Ú__classcell__)r   s   @r   r   r       s¯   ø„ ñð&àð&ð ð&ð ˜˜E˜	Ñ"ð	&ð
 ð&ð 
õ&ð0 ð˜˜q !˜t™ô ó ðð
 ñ˜5 4™<ð °4¸¸aÀ¸d¹Ñ3Dô ó ðð(˜Að ( $÷ (r   r   N)r+   Úcollections.abcr   Útypingr   Ú
cachetoolsr   Útyping_extensionsr   Ú%streamlit.runtime.caching.cache_utilsr   r   r	   r   © r   r   ú<module>r6      sB   ðñ Zå $Ý å õ 'å ;áˆCƒL€ÙˆCƒL€ô5(�h˜q !˜t‘nõ 5(r   