o
    ýÞh‡  ã                   @   sò   d Z dZddlZddlZddlZzddlmZ W n ey'   ddlmZ Y nw ddl	m
Z
mZmZmZmZmZ ddl	mZ ddl	mZ G d	d
„ d
eƒZdd„ Zddd„Zddd„Zddd„Zddd„Zdejdfdd„Zddejdfdd„ZdS )z?`functools.lru_cache` compatible memoizing function decorators.)Ú
fifo_cacheÚ	lfu_cacheÚ	lru_cacheÚ	mru_cacheÚrr_cacheÚ	ttl_cacheé    N)ÚRLocké   )Ú	FIFOCacheÚLFUCacheÚLRUCacheÚMRUCacheÚRRCacheÚTTLCache)Úcached)Úkeysc                   @   s    e Zd Zdd„ Zedd„ ƒZdS )Ú_UnboundTTLCachec                 C   s   t  | tj||¡ d S ©N)r   Ú__init__ÚmathÚinf)ÚselfÚttlÚtimer© r   úO/var/www/html/premium_crap/venv/lib/python3.10/site-packages/cachetools/func.pyr      s   z_UnboundTTLCache.__init__c                 C   s   d S r   r   )r   r   r   r   Úmaxsize   s   z_UnboundTTLCache.maxsizeN)Ú__name__Ú
__module__Ú__qualname__r   Úpropertyr   r   r   r   r   r      s    r   c                    s   ‡ ‡‡fdd„}|S )Nc                    s:   ˆrt jnt j}tˆ |tƒ dd�| ƒ}‡‡fdd„|_|S )NT)ÚcacheÚkeyÚlockÚinfoc                      s
   ˆ ˆdœS )N©r   Útypedr   r   r%   r   r   Ú<lambda>    s   
 z+_cache.<locals>.decorator.<locals>.<lambda>)r   ÚtypedkeyÚhashkeyr   r   Úcache_parameters)Úfuncr"   Úwrapper©r!   r   r&   r   r   Ú	decorator   s   z_cache.<locals>.decoratorr   )r!   r   r&   r.   r   r-   r   Ú_cache   s   r/   é€   Fc                 C   ó@   | du r
t i d|ƒS t| ƒrt tdƒd|ƒ| ƒS t t| ƒ| |ƒS )z—Decorator to wrap a function with a memoizing callable that saves
    up to `maxsize` results based on a First In First Out (FIFO)
    algorithm.

    Nr0   )r/   Úcallabler
   r%   r   r   r   r   &   ó
   r   c                 C   r1   )z™Decorator to wrap a function with a memoizing callable that saves
    up to `maxsize` results based on a Least Frequently Used (LFU)
    algorithm.

    Nr0   )r/   r2   r   r%   r   r   r   r   4   r3   r   c                 C   r1   )z—Decorator to wrap a function with a memoizing callable that saves
    up to `maxsize` results based on a Least Recently Used (LRU)
    algorithm.

    Nr0   )r/   r2   r   r%   r   r   r   r   B   r3   r   c                 C   sZ   ddl m} |dtdd� | du rti d|ƒS t| ƒr%ttdƒd|ƒ| ƒS tt| ƒ| |ƒS )z•Decorator to wrap a function with a memoizing callable that saves
    up to `maxsize` results based on a Most Recently Used (MRU)
    algorithm.
    r   )Úwarnz@mru_cache is deprecatedé   )Ú
stacklevelNr0   )Úwarningsr4   ÚDeprecationWarningr/   r2   r   )r   r&   r4   r   r   r   r   P   s   r   c                 C   sD   | du r
t i d|ƒS t| ƒrt td|ƒd|ƒ| ƒS t t| |ƒ| |ƒS )z•Decorator to wrap a function with a memoizing callable that saves
    up to `maxsize` results based on a Random Replacement (RR)
    algorithm.

    Nr0   )r/   r2   r   )r   Úchoicer&   r   r   r   r   a   s
   r   iX  c                 C   sN   | du rt t||ƒd|ƒS t| ƒrt td||ƒd|ƒ| ƒS t t| ||ƒ| |ƒS )z¿Decorator to wrap a function with a memoizing callable that saves
    up to `maxsize` results based on a Least Recently Used (LRU)
    algorithm with a per-item time-to-live (TTL) value.
    Nr0   )r/   r   r2   r   )r   r   r   r&   r   r   r   r   o   s
   r   )r0   F)Ú__doc__Ú__all__r   ÚrandomÚtimeÚ	threadingr   ÚImportErrorÚdummy_threadingÚ r
   r   r   r   r   r   r   r   r   r/   r   r   r   r   r9   r   Ú	monotonicr   r   r   r   r   Ú<module>   s*    ÿ 	




