3 M(Y @sdZddlmZddlZddlZddlZddlZyddlmZWn e k r`ddl mZYnXddl m Z ddl mZddlmZdd lmZdd lmZdZejdddddgZdddZddd Zd dd Zdejdfdd ZddejdfddZdS)!z?`functools.lru_cache` compatible memoizing function decorators.)absolute_importN)RLock)keys)LFUCache)LRUCache)RRCache)TTLCache lfu_cache lru_cacherr_cache ttl_cache CacheInfohitsmissesmaxsizecurrsizeFcsfdd}|S)Ncs~r tjntjtddgfdd}fdd}fdd}tj|t|dsn|_||_||_ |S) Nrc s2\}}j}j}WdQRXt||||S)N)rr _CacheInfo)rrrr)cachelockstats=/private/tmp/pip-build-nl73fm5q/cachetools/cachetools/func.py cache_info#s z-_cache..decorator..cache_infocs4&z jWdddgdd<XWdQRXdS)Nr)clearr)rrrrr cache_clear*s z._cache..decorator..cache_clearcs||}Hy|}dd7<|Stk rPdd7<YnXWdQRX||}y||<WdQRXWntk rYnX|S)Nrr)KeyError ValueError)argskwargskv)rfunckeyrrrrwrapper1s   z*_cache..decorator..wrapper __wrapped__) rZtypedkeyZhashkeyr functoolsupdate_wrapperhasattrr%rr)r"rrr$)rtyped)r"r#rrr decorators  z_cache..decoratorr)rr)r*r)rr)r_caches)r+cCstt||S)zDecorator to wrap a function with a memoizing callable that saves up to `maxsize` results based on a Least Frequently Used (LFU) algorithm. )r+r)rr)rrrr JscCstt||S)zDecorator to wrap a function with a memoizing callable that saves up to `maxsize` results based on a Least Recently Used (LRU) algorithm. )r+r)rr)rrrr SscCstt|||S)zDecorator to wrap a function with a memoizing callable that saves up to `maxsize` results based on a Random Replacement (RR) algorithm. )r+r)rchoicer)rrrr \siXcCstt||||S)zDecorator to wrap a function with a memoizing callable that saves up to `maxsize` results based on a Least Recently Used (LRU) algorithm with a per-item time-to-live (TTL) value. )r+r )rttlZtimerr)rrrr es)r r r r )F)r,F)r,F)__doc__ __future__r collectionsr&randomtime threadingr ImportErrordummy_threadingrZlfurZlrurZrrrr.r __all__ namedtuplerr+r r r-r r rrrrs,       -