o
    !§ÑhÞ  ã                   @   sN   d dl mZ d dlmZmZmZ edƒZedƒZG dd„ deeef eƒZdS )é    )ÚOrderedDict)ÚDictÚGenericÚTypeVarÚCacheKeyÚ
CacheValuec                       s^   e Zd ZdZdeddf‡ fdd„Zdededdfd	d
„Zde	eef dedefdd„Z
‡  ZS )ÚLRUCachezÔ
    A dictionary-like container that stores a given maximum items.

    If an additional item is added when the LRUCache is full, the least
    recently used key is discarded to make room for the new item.

    Ú
cache_sizeÚreturnNc                    s   || _ tt| ƒ ¡  d S )N)r	   Úsuperr   Ú__init__)Úselfr	   ©Ú	__class__© ú=/usr/lib/python3/dist-packages/pip/_vendor/rich/_lru_cache.pyr      s   zLRUCache.__init__ÚkeyÚvaluec                 C   s4   || vrt | ƒ| jkr| jdd� t | ||¡ dS )z7Store a new views, potentially discarding an old value.F)ÚlastN)Úlenr	   Úpopitemr   Ú__setitem__©r   r   r   r   r   r   r      s   zLRUCache.__setitem__r   c                 C   s*   t  | |¡}t  | |¡ t  | ||¡ |S )z-Gets the item, but also makes it most recent.)r   Ú__getitem__Ú__delitem__r   r   r   r   r   r      s   zLRUCache.__getitem__)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úintr   r   r   r   r   r   Ú__classcell__r   r   r   r   r   	   s
    &r   N)	Úcollectionsr   Útypingr   r   r   r   r   r   r   r   r   r   Ú<module>   s
    