
    ob                         d Z ddlmZmZ ddlZddlmZ  ej                  d      Z ej                  d      Z	 G d deej                  ee	f         Zy)	z#Least Recently Used cache mapping.
    )absolute_importunicode_literalsN)OrderedDict_K_Vc                   2     e Zd ZdZ fdZd Z fdZ x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                 8    || _         t        t        |           y)z*Create a new LRUCache with the given size.N)
cache_sizesuperr	   __init__)selfr   	__class__s     -/usr/lib/python3/dist-packages/fs/lrucache.pyr   zLRUCache.__init__   s     %h&(    c                     || vr*t        |       | j                  k\  r| j                  d       t        j                  | ||       y)z7Store a new views, potentially discarding an old value.F)lastN)lenr   popitemr   __setitem__)r   keyvalues      r   r   zLRUCache.__setitem__   s;     d?4yDOO+%(c51r   c                     t        j                  t        t        t        |             }|j                  |      }|j                  |       |j                  ||       |S )z,Get the item, but also makes it most recent.)typingcastr   r   r	   __getitem____delitem__r   )r   r   _superr   r   s       r   r   zLRUCache.__getitem__$   sO     [%$*?@""3'33&r   )__name__
__module____qualname____doc__r   r   r   __classcell__)r   s   @r   r	   r	      s    )2 r   r	   )r"   
__future__r   r   r   collectionsr   TypeVarr   r   Genericr	    r   r   <module>r)      sP    9  #V^^DV^^D{FNN2r62 r   