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
    