o
    pf                     @   s\   d Z ddlmZmZ ddlZddlmZ edZedZ	G dd deej
ee	f ZdS )	z#Least Recently Used cache mapping.
    )absolute_importunicode_literalsN)OrderedDict_K_Vc                       s4   e Zd ZdZ fddZdd Z fddZ  ZS )LRUCachezA 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.

    c                    s   || _ tt|   dS )z*Create a new LRUCache with the given size.N)
cache_sizesuperr   __init__)selfr   	__class__ D/home/ertert/spirit/venv/lib/python3.10/site-packages/fs/lrucache.pyr
      s   zLRUCache.__init__c                 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   keyvaluer   r   r   r      s   zLRUCache.__setitem__c                    s6   t ttt| }||}|| ||| |S )z,Get the item, but also makes it most recent.)typingcastr   r	   r   __getitem____delitem__r   )r   r   _superr   r   r   r   r   $   s
   

zLRUCache.__getitem__)__name__
__module____qualname____doc__r
   r   r   __classcell__r   r   r   r   r      s
    r   )r   
__future__r   r   r   collectionsr   TypeVarr   r   Genericr   r   r   r   r   <module>   s    

 