a
    |=icF                     @   s  d Z dZddlZddl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0 ddlmZmZmZmZmZmZ ddlmZ edg d	ZG d
d de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)keys	CacheInfo)hitsmissesmaxsizecurrsizec                   @   s$   e Zd Zedd Zedd ZdS )_UnboundCachec                 C   s   d S N selfr   r   `/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/cachetools/func.pyr      s    z_UnboundCache.maxsizec                 C   s   t | S r   )lenr   r   r   r   r      s    z_UnboundCache.currsizeN)__name__
__module____qualname__propertyr   r   r   r   r   r   r      s   
r   c                   @   s    e Zd Zdd Zedd ZdS )_UnboundTTLCachec                 C   s   t | tj|| d S r   )r   __init__mathinf)r   ttltimerr   r   r   r"   $   s    z_UnboundTTLCache.__init__c                 C   s   d S r   r   r   r   r   r   r   '   s    z_UnboundTTLCache.maxsizeN)r   r   r   r"   r    r   r   r   r   r   r!   #   s   r!   c                    s    j  fdd}|S )Nc                    s   r
t jnt jd t  fdd}fdd}fdd}||_||_fdd	|_t|  |S )
Nr   c               	      s   | i |}P z$ | }d7 |W W  d    S  t yR   d7 Y n0 W d    n1 sh0    Y  | i |}z6  ||W  d    W S 1 s0    Y  W n ty   | Y S 0 d S )Nr	   )KeyError
setdefault
ValueError)argskwargskv)cachefuncr   keylockr   r   r   wrapper4   s    ,0z*_cache.<locals>.decorator.<locals>.wrapperc                     s>     j }  j}W d    n1 s&0    Y  t| |S r   )r   r   
_CacheInfo)r   r   r.   r   r1   r   r   r   
cache_infoF   s    $z-_cache.<locals>.decorator.<locals>.cache_infoc                	      sH   0 z    W d n
d 0 W d    n1 s:0    Y  d S )Nr   )clearr   r4   r   r   cache_clearL   s    
z._cache.<locals>.decorator.<locals>.cache_clearc                      s
    dS )Nr   typedr   r   r8   r   r   <lambda>V       z+_cache.<locals>.decorator.<locals>.<lambda>)	r   ZtypedkeyZhashkeyr   r5   r7   cache_parameters	functoolsupdate_wrapper)r/   r2   r5   r7   r.   r   r9   )r/   r   r0   r1   r   r   	decorator/   s    z_cache.<locals>.decorator)r   )r.   r9   r@   r   r?   r   _cache,   s    +rA      Fc                 C   s@   | du rt t |S t| r.t td|| S t t| |S dS )zDecorator to wrap a function with a memoizing callable that saves
    up to `maxsize` results based on a First In First Out (FIFO)
    algorithm.

    NrB   )rA   r   callabler
   r8   r   r   r   r   ]   s
    r   c                 C   s@   | du rt t |S t| r.t td|| S t t| |S dS )zDecorator to wrap a function with a memoizing callable that saves
    up to `maxsize` results based on a Least Frequently Used (LFU)
    algorithm.

    NrB   )rA   r   rC   r   r8   r   r   r   r   k   s
    r   c                 C   s@   | du rt t |S t| r.t td|| S t t| |S dS )zDecorator to wrap a function with a memoizing callable that saves
    up to `maxsize` results based on a Least Recently Used (LRU)
    algorithm.

    NrB   )rA   r   rC   r   r8   r   r   r   r   y   s
    r   c                 C   s@   | du rt t |S t| r.t td|| S t t| |S dS )zDecorator to wrap a function with a memoizing callable that saves
    up to `maxsize` results based on a Most Recently Used (MRU)
    algorithm.
    NrB   )rA   r   rC   r   r8   r   r   r   r      s
    r   c                 C   sD   | du rt t |S t| r0t td||| S t t| ||S dS )zDecorator to wrap a function with a memoizing callable that saves
    up to `maxsize` results based on a Random Replacement (RR)
    algorithm.

    NrB   )rA   r   rC   r   )r   choicer9   r   r   r   r      s
    r   iX  c                 C   sL   | du rt t|||S t| r6t td|||| S t t| |||S dS )zDecorator 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.
    NrB   )rA   r!   rC   r   )r   r%   r&   r9   r   r   r   r      s
    r   )rB   F)rB   F)rB   F)rB   F)!__doc____all__collectionsr=   r#   randomtime	threadingr   ImportErrorZdummy_threading r
   r   r   r   r   r   r   
namedtupler3   dictr   r!   rA   r   r   r   r   rD   r   	monotonicr   r   r   r   r   <module>   s0    
	1



