HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: sport3497 (1034)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib64/python3.10/site-packages/cachetools/__pycache__/__init__.cpython-310.pyc
o

�h+U�@s,dZdZdZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZGdd	�d	�Z
Gd
d�dejj�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Ze�dgd��Ze
jddfdd �Ze
jdfd!d"�ZdS)#z0Extensible memoizing collections and decorators.)
�Cache�	FIFOCache�LFUCache�LRUCache�MRUCache�RRCache�	TLRUCache�TTLCache�cached�cachedmethodz5.5.2�N�)�keys)�_cached_wrapperc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_DefaultSize�cC�dS�Nrr��self�_rr�F/usr/local/CyberCP/lib/python3.10/site-packages/cachetools/__init__.py�__getitem__ �z_DefaultSize.__getitem__cCs|dksJ�dSrr)rr�valuerrr�__setitem__#sz_DefaultSize.__setitem__cCrrrrrrr�pop&rz_DefaultSize.popN)�__name__�
__module__�__qualname__�	__slots__rrrrrrrrs
rc@s�eZdZdZe�Ze�Zd!dd�Zdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�Zd!dd�Zefdd�Zd!dd�Zedd��Zedd��Zedd ��ZdS)"rz?Mutable mapping to serve as a simple cache or cache base class.NcCs6|r||_|jtjurt�|_t�|_d|_||_dS�Nr)�	getsizeofr�dict�_Cache__size�_Cache__data�_Cache__currsize�_Cache__maxsize�r�maxsizer!rrr�__init__1s
zCache.__init__cCsd|jjt|j�|j|jfS)Nz%s(%s, maxsize=%r, currsize=%r))�	__class__r�reprr$r&r%�rrrr�__repr__:s�zCache.__repr__cCs*z|j|WSty|�|�YSw�N)r$�KeyError�__missing__�r�keyrrrrBs
�zCache.__getitem__cCs�|j}|�|�}||krtd��||jvs|j||kr.|j||kr.|��|j||ks#||jvr;||j|}n|}||j|<||j|<|j|7_dS)Nzvalue too large)r&r!�
ValueErrorr$r#r%�popitem)rr2rr(�size�diffsizerrrrHs
�


zCache.__setitem__cCs&|j�|�}|j|=|j|8_dSr.)r#rr$r%)rr2r5rrr�__delitem__XszCache.__delitem__cCs
||jvSr.)r$r1rrr�__contains__]�
zCache.__contains__cCst|��r.)r/r1rrrr0`szCache.__missing__cC�
t|j�Sr.)�iterr$r,rrr�__iter__cr9zCache.__iter__cCr:r.)�lenr$r,rrr�__len__fr9z
Cache.__len__cCs||vr||S|Sr.r)rr2�defaultrrr�getisz	Cache.getcCs4||vr
||}||=|S||jurt|��|}|Sr.)�_Cache__markerr/�rr2r?rrrrros
�z	Cache.popcCs$||vr
||}|S|||<}|Sr.rrBrrr�
setdefaultys
�zCache.setdefaultcC�|jS)zThe maximum size of the cache.)r&r,rrrr(��z
Cache.maxsizecCrD)zThe current size of the cache.)r%r,rrr�currsize�rEzCache.currsizecCr)z+Return the size of a cache element's value.rr)rrrrr!�szCache.getsizeofr.)rrr�__doc__�objectrArr#r)r-rrr7r8r0r<r>r@rrC�propertyr(rF�staticmethodr!rrrrr*s,
	




rc@s>eZdZdZddd�Zejfdd�Zejfdd�Zd	d
�ZdS)rz/First In First Out (FIFO) cache implementation.NcC�t�|||�t��|_dSr.)rr)�collections�OrderedDict�_FIFOCache__orderr'rrrr)��zFIFOCache.__init__cCs>||||�z	|j�|�WdStyd|j|<YdSwr.)rN�move_to_endr/�rr2r�
cache_setitemrrrr�s�zFIFOCache.__setitem__cC�|||�|j|=dSr.)rN�rr2�
cache_delitemrrrr7��
zFIFOCache.__delitem__cC�Dz	tt|j��}Wntytdt|�j�d�w||�|�fS)z9Remove and return the `(key, value)` pair first inserted.�%s is emptyN)�nextr;rN�
StopIterationr/�typerrr1rrrr4���zFIFOCache.popitemr.)	rrrrGr)rrr7r4rrrrr�s
rc@sLeZdZdZd
dd�Zejfdd�Zejfdd�Zejfd	d
�Zdd�Z	dS)rz1Least Frequently Used (LFU) cache implementation.NcCrKr.)rr)rL�Counter�_LFUCache__counterr'rrrr)�rOzLFUCache.__init__cCs(|||�}||vr|j|d8<|Sr�r^�rr2�
cache_getitemrrrrr�s
zLFUCache.__getitem__cCs"||||�|j|d8<dSrr_rQrrrr�szLFUCache.__setitem__cCrSr.r_rTrrrr7�rVzLFUCache.__delitem__cCsHz|j�d�\\}}Wntytdt|�j�d�w||�|�fS)z@Remove and return the `(key, value)` pair least frequently used.rrXN)r^�most_commonr3r/r[rr)rr2rrrrr4�s�zLFUCache.popitemr.)
rrrrGr)rrrr7r4rrrrr�s
rc@�TeZdZdZddd�Zejfdd�Zejfdd�Zejfd	d
�Zdd�Z	d
d�Z
dS)rz/Least Recently Used (LRU) cache implementation.NcCrKr.)rr)rLrM�_LRUCache__orderr'rrrr)�rOzLRUCache.__init__cC� |||�}||vr|�|�|Sr.��_LRUCache__updater`rrrr��

zLRUCache.__getitem__cC�||||�|�|�dSr.rfrQrrrr��zLRUCache.__setitem__cCrSr.)rdrTrrrr7�rVzLRUCache.__delitem__cCrW)z>Remove and return the `(key, value)` pair least recently used.rXN)rYr;rdrZr/r[rrr1rrrr4�r\zLRUCache.popitemcCs2z	|j�|�WdStyd|j|<YdSwr.)rdrPr/r1rrr�__update�s
�zLRUCache.__updater.)rrrrGr)rrrr7r4rgrrrrr�s
	rc@rc)rz.Most Recently Used (MRU) cache implementation.NcCs6ddlm}|dtdd�t�|||�t��|_dS)Nr)�warnzMRUCache is deprecated�)�
stacklevel)�warningsrl�DeprecationWarningrr)rLrM�_MRUCache__order)rr(r!rlrrrr)�szMRUCache.__init__cCrer.��_MRUCache__updater`rrrr�rhzMRUCache.__getitem__cCrir.rrrQrrrrrjzMRUCache.__setitem__cCrSr.)rqrTrrrr7rVzMRUCache.__delitem__cCrW)z=Remove and return the `(key, value)` pair most recently used.rXN)rYr;rqrZr/r[rrr1rrrr4	r\zMRUCache.popitemcCs6z|jj|dd�WdStyd|j|<YdSw)NF)�last)rqrPr/r1rrrrks
�zMRUCache.__updater.)rrrrGr)rrrr7r4rsrrrrr�s
	rc@s4eZdZdZejdfdd�Zedd��Zdd�ZdS)	rz-Random Replacement (RR) cache implementation.NcCst�|||�||_dSr.)rr)�_RRCache__choice)rr(�choicer!rrrr)s
zRRCache.__init__cCrD)z(The `choice` function used by the cache.)rur,rrrrv rEzRRCache.choicecCsDz	|�t|��}Wntytdt|�j�d�w||�|�fS)z/Remove and return a random `(key, value)` pair.rXN)ru�list�
IndexErrorr/r[rrr1rrrr4%r\zRRCache.popitem)	rrrrG�randomrvr)rIr4rrrrrs
rcs�eZdZdZGdd�d�Zejdfdd�Zej	fdd�Z	ej
fd	d
�Z
e�fdd��Zed
d��Z
dd�Zdd�Zdd�Zdd�Z�ZS)�_TimedCachez0Base class for time aware cache implementations.c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)z_TimedCache._TimercCs||_d|_dSr )�
_Timer__timer�_Timer__nesting)r�timerrrrr)3�
z_TimedCache._Timer.__init__cCs|jdkr	|��S|jSr �r|r{�_Timer__timer,rrr�__call__7s
z_TimedCache._Timer.__call__cCs2|jdkr
|��|_}n|j}|jd7_|S)Nrrr�r�timerrr�	__enter__=s

z_TimedCache._Timer.__enter__cGs|jd8_dSr)r|)r�excrrr�__exit__E�z_TimedCache._Timer.__exit__cCstj|jffSr.)rz�_Timerr{r,rrr�
__reduce__H�z_TimedCache._Timer.__reduce__cCst|j|�Sr.)�getattrr{)r�namerrr�__getattr__K�z_TimedCache._Timer.__getattr__N)	rrrr)r�r�r�r�r�rrrrr�2sr�NcCst�|||�t�|�|_dSr.)rr)rzr��_TimedCache__timer)rr(r}r!rrrr)Nsz_TimedCache.__init__cC�<|j�}|�|�||�Wd�S1swYdSr.�r��expire)r�
cache_reprr�rrrr-R�
$�z_TimedCache.__repr__cCr�r.r�)r�	cache_lenr�rrrr>Wr�z_TimedCache.__len__cs<|j�}|�|�t�jWd�S1swYdSr.)r�r��superrFr��r*rrrF\s
$�z_TimedCache.currsizecCrD)z%The timer function used by the cache.)r�r,rrrr}brEz_TimedCache.timercCs@|j�}|�|�t�|�Wd�dS1swYdSr.)r�r�r�clearr�rrrr�gs
"�z_TimedCache.clearcO�B|j�tj|g|�Ri|��Wd�S1swYdSr.)r�rr@�r�args�kwargsrrrr@l�$�z_TimedCache.getcOr�r.)r�rrr�rrrrpr�z_TimedCache.popcOr�r.)r�rrCr�rrrrCtr�z_TimedCache.setdefault)rrrrGr�r��	monotonicr)rr-r>rIrFr}r�r@rrC�
__classcell__rrr�rrz/s
rzc@s�eZdZdZGdd�d�Zejdfdd�Zdd�Ze	j
fd	d
�Z
e	jfdd�Ze	jfd
d�Zdd�Z
dd�Zedd��Zddd�Zdd�Zdd�ZdS)rz@LRU Cache implementation with per-item time-to-live (TTL) value.c@s*eZdZdZd	dd�Zdd�Zdd�ZdS)
zTTLCache._Link)r2�expiresrY�prevNcCs||_||_dSr.)r2r��rr2r�rrrr)r~zTTLCache._Link.__init__cCstj|j|jffSr.)r�_Linkr2r�r,rrrr��r�zTTLCache._Link.__reduce__cCs|j}|j}||_||_dSr.)rYr�)rrYr�rrr�unlink�s
zTTLCache._Link.unlink�NN)rrrrr)r�r�rrrrr�|s

r�NcCs>t�||||�t��|_}||_|_t��|_	||_
dSr.)rzr)rr��_TTLCache__rootr�rYrLrM�_TTLCache__links�_TTLCache__ttl)rr(�ttlr}r!�rootrrrr)�s


zTTLCache.__init__cC�2z|j|}Wn
tyYdSw|��|jkS�NF)r�r/r}r�)rr2�linkrrrr8���zTTLCache.__contains__cC�Nz|�|�}Wntyd}Yn	w|��|jk}|r"|�|�S|||�Sr�)�_TTLCache__getlinkr/r}r�r0)rr2rar��expiredrrrr���

zTTLCache.__getitem__cCs�|j�}|�|�||||�Wd�n1swYz|�|�}Wnty8t�|�|j|<}Ynw|��||j|_	|j
|_}|j|_}||_|_dSr.)
r}r�r�r/rr�r�r�r�r�r�rYr�)rr2rrRr�r�r�r�rrrr�s
��zTTLCache.__setitem__cCs8|||�|j�|�}|��|��|jkst|��dSr.)r�rr�r}r�r/)rr2rUr�rrrr7�s
�zTTLCache.__delitem__ccsd�|j}|j}||ur0|j�}||jkr|jVWd�n1s"wY|j}||usdSdSr.)r�rYr}r�r2)rr��currr�rrrr<�s�
���zTTLCache.__iter__cCsj|j�|�|j}||_|_t|j��dd�d�D]}||_|j|_}||_|_q|�|�	��dS)NcSrDr.�r�)�objrrr�<lambda>�sz'TTLCache.__setstate__.<locals>.<lambda>)r2)
�__dict__�updater�r�rY�sortedr��valuesr�r})r�stater�r�r�rrr�__setstate__�szTTLCache.__setstate__cCrD)z,The time-to-live value of the cache's items.)r�r,rrrr��rEzTTLCache.ttlc	Cs�|dur|��}|j}|j}|j}g}tj}tj}||urJ||jksJ|�|j	|||j	�f�|||j	�||j	=|j}|�
�|}||urJ||jkr"|S)�qRemove expired items from the cache and return an iterable of the
        expired `(key, value)` pairs.

        N)r}r�rYr�rr7rr��appendr2r�)	rr�r�r��linksr�rUrarYrrrr��s"�zTTLCache.expirec	Csx|j�/}|�|�z	tt|j��}Wnty#tdt|�j�d�w||�	|�fWd�S1s5wYdS�zmRemove and return the `(key, value)` pair least recently used that
        has not already expired.

        rXN)
r}r�rYr;r�rZr/r[rr�rr�r2rrrr4�s
�$�zTTLCache.popitemcC�|j|}|j�|�|Sr.)r�rP�rr2rrrr�	__getlink��
zTTLCache.__getlinkr.)rrrrGr�r�r�r)r8rrrr7r<r�rIr�r�r4r�rrrrrys



rc@s�eZdZdZejGdd�d��Zejdfdd�Z	dd�Z
ejfd	d
�Zej
fdd�Z
ejfd
d�Zdd�Zedd��Zddd�Zdd�Zdd�ZdS)rz;Time aware Least Recently Used (TLRU) cache implementation.c@s"eZdZdZddd�Zdd�ZdS)zTLRUCache._Item�r2r��removedNcCs||_||_d|_dSr�r�r�rrrr)s
zTLRUCache._Item.__init__cCs|j|jkSr.r�)r�otherrrr�__lt__r�zTLRUCache._Item.__lt__r�)rrrrr)r�rrrr�_Items
r�NcCs*t�||||�t��|_g|_||_dSr.)rzr)rLrM�_TLRUCache__items�_TLRUCache__order�_TLRUCache__ttu)rr(�ttur}r!rrrr)s

zTLRUCache.__init__cCr�r�)r�r/r}r�)rr2�itemrrrr8r�zTLRUCache.__contains__cCr�r�)�_TLRUCache__getitemr/r}r�r0)rr2rar�r�rrrrr�zTLRUCache.__getitem__cCs�|j�'}|�|||�}||ks	Wd�dS|�|�||||�Wd�n1s-wYzd|�|�_Wn	tyCYnwt�||�|j|<}t	�
|j|�dS�NT)r}r�r�r�r�r/rr�r��heapq�heappushr�)rr2rrRr�r�r�rrrr)s�
��zTLRUCache.__setitem__cCsX|j�
}|||�Wd�n1swY|j�|�}d|_||jks*t|��dSr�)r}r�rr�r�r/)rr2rUr�r�rrrr79s�
�zTLRUCache.__delitem__c	csP�|jD]!}|j�}||jkr|js|jVWd�n1s wYqdSr.)r�r}r�r�r2)rr�r�rrrr<Bs�
����zTLRUCache.__iter__cCrD)z1The local time-to-use function used by the cache.)r�r,rrrr�IrEz
TLRUCache.ttucCs�|dur|��}|j}|j}t|�t|�dkr'dd�|D�|_}t�|�g}tj}tj}|ri|dj	s=||dj
ksit�|�}|j	s[|�|j
|||j
�f�|||j
�||j
=|ri|dj	s=||dj
kr=|S)r�NrmcSsg|]}|js|�qSr)r�)�.0r�rrr�
<listcomp>Ysz$TLRUCache.expire.<locals>.<listcomp>r)r}r�r�r=r��heapifyrr7rr�r��heappopr�r2)rr��items�orderr�rUrar�rrrr�Ns$

�zTLRUCache.expirec	Csv|j�.}|�|�z	tt|j��}Wnty"td|jj�d�w||�	|�fWd�S1s4wYdSr�)
r}r�rYr;r�rZr/r*rrr�rrrr4fs
�$�zTLRUCache.popitemcCr�r.)r�rPr�rrr�	__getitemtr�zTLRUCache.__getitemr.)rrrrG�	functools�total_orderingr�r�r�r)r8rrrr7r<rIr�r�r4r�rrrrrs	

r�	CacheInfo)�hits�missesr(rFFcs����fdd�}|S)z_Decorator to wrap a function with a memoizing callable that saves
    results in a cache.

    cs��r)t�t�r�fdd�}nt�tjj�r�fdd�}ndd�}t|���|�}nt|���d�}�|_�|_�|_t	�
||�S)Ncst||�j�j�Sr.)�
_CacheInfor(rF�r�r���cacherr�	make_info�r�z,cached.<locals>.decorator.<locals>.make_infocst||dt���Sr.)r�r=r�r�rrr��r�cSst||dd�Sr )r�r�rrrr��r�)�
isinstancerrL�abc�Mappingrr��	cache_key�
cache_lockr��update_wrapper)�funcr��wrapper�r��infor2�lockrr�	decorator�s
zcached.<locals>.decoratorr)r�r2r�r�r�rr�rr	sr	cs���fdd�}|S)zoDecorator to wrap a class or instance method with a memoizing
    callable that saves results in a cache.

    csj�dur���fdd�}�fdd�}n����fdd�}��fdd�}�|_�|_�|_||_t�|��S)Ncs��|�}|dur�|g|�Ri|��S�|g|�Ri|��}z||WSty,Ynw�|g|�Ri|��}z|||<W|StyIY|Swr.)r/r3�rr�r��c�k�v)r�r2�methodrrr��s"
�
��z0cachedmethod.<locals>.decorator.<locals>.wrappercs �|�}|dur|��dSdSr.�r��rr�r�rrr��s�z.cachedmethod.<locals>.decorator.<locals>.clearcs��|�}|dur�|g|�Ri|��S�|g|�Ri|��}z�|��
||Wd�WS1s3wYWn	tyBYnw�|g|�Ri|��}z�|��|�||�Wd�WS1sewYWdStyw|YSwr.)r/rCr3r�)r�r2r�r�rrr��s&
&��

(��csJ�|�}|dur#�|��
|��Wd�dS1swYdSdSr.r�r�)r�r�rrr��s

"��)r�r�r��cache_clearr�r�)r�r�r��r�r2r�)r�rr��szcachedmethod.<locals>.decoratorr)r�r2r�r�rr�rr
�s9r
)rG�__all__�__version__rL�collections.abcr�r�ryr��r
�_decoratorsrrr��MutableMappingrrrrrrrzrr�
namedtupler��hashkeyr	�	methodkeyr
rrrr�<module>s6

f%)Jz�$