B *]@sHdZddlmZddlmZddlmZeddddd gZdd d Zd S)z LRU cache implementation for Python 2.7 Ported from http://code.activestate.com/recipes/578078/ and simplified for our use (only support maxsize > 0 and positional arguments). ) namedtuple)update_wrapper)RLock CacheInfohitsmissesmaxsizecurrsizedcsfdd}|S)zLeast-recently-used cache decorator. Arguments to the cached function must be hashable. See: http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used cstddg d\jtt g}||ddg|dd<|g d\ r\ dkshtd  fdd} fdd} fd d } |_||_||_t| S) Nr)r)rr zmaxsize %s not supportedc sB|} t|}|dk rx \}|\}}}}||<||<|}||<|<||<||< d7<|SWdQRX |}  \}|krn kr|}||<||<|} d<|} d|<|<| =||<n,|}||||g}||<|<|< d7<WdQRX|S)Nr r) argskeylinkrootZ link_prevZ link_nextresultZlastZoldrootZoldkey)HITSKEYMISSESNEXTPREVRESULT_lencache cache_getlockr nonlocal_rootstats user_functionrF/opt/alt/python37/lib64/python3.7/site-packages/psycopg2/_lru_cache.pywrapper&sB    z7lru_cache..decorating_function..wrapperc s*ttSQRXdS)zReport cache statisticsN) _CacheInfolenr)rrrrrrrr! cache_infoVsz:lru_cache..decorating_function..cache_infoc sH:d}||ddg|dd<ddgdd<WdQRXdS)z$Clear the cache and cache statisticsrN)clear)r)rrrrrr! cache_clear[s z;lru_cache..decorating_function..cache_clear) dictgetr$rAssertionError __wrapped__r%r'r)r rr"r%r')r) rrrrrrrrrrrrr r!decorating_functions$ &0z&lru_cache..decorating_functionr)rr,r)rr! lru_caches Qr-N)r ) __doc__ collectionsr functoolsrZ threadingrr#r-rrrr!s