3 M(ÌYËã@s4ddlmZddlZddlmZGdd„deƒZdS)é)Úabsolute_importNé)ÚCachec@sjeZdZdZddd„Zejfdd„Zejfdd„Zejfd d „Zd d „Z e e j d ƒr^dd„Z ndd„Z dS)ÚLRUCachez/Least Recently Used (LRU) cache implementation.NcCstj||||ƒtjƒ|_dS)N)rÚ__init__Ú collectionsÚ OrderedDictÚ_LRUCache__order)ÚselfÚmaxsizeÚmissingÚ getsizeof©rúRemove and return the `(key, value)` pair least recently used.z %s is emptyN)ÚnextÚiterr Ú StopIterationÚKeyErrorÚ __class__Ú__name__Úpop)r rrrrÚpopitems zLRUCache.popitemÚ move_to_endc Cs4y|jj|ƒWntk r.d|j|<YnXdS)N)r rr)r rrrrÚ__update&szLRUCache.__updatec Cs:y|jj|ƒ|j|<Wntk r4d|j|<YnXdS)N)r rr)r rrrrr,s)NN)rÚ __module__Ú __qualname__Ú__doc__rrrrrrÚhasattrrrrrrrrrs   r)Ú __future__rrÚcacherrrrrrÚs