
                         z   S r SSKJr  SSKrSSKrSSKr SSKJr   SSK
Jr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  Sr\R0                  " S/ SQ5      r " S S\5      r " S S\5      rSS jrSS jrSS jrS\R@                  S4S jr!SS\S4S jr"g! \	 a	    SSKJr   Nf = f! \	 a	    SSKJr   Nf = f)z?`functools.lru_cache` compatible memoizing function decorators.    )absolute_importN)	monotonic)time)RLock   )keys)LFUCache)LRUCache)RRCache)TTLCache)	lfu_cache	lru_cacherr_cache	ttl_cache	CacheInfo)hitsmissesmaxsizecurrsizec                   (    \ rS rSrSr\S 5       rSrg)_UnboundCache   Nc                     [        U 5      $ N)lenselfs    "lib/third_party/cachetools/func.pyr   _UnboundCache.currsize#   s    t9     )__name__
__module____qualname____firstlineno__r   propertyr   __static_attributes__r!   r    r   r   r      s    ' r    r   c                   *    \ rS rSrS r\S 5       rSrg)_UnboundTTLCache(   c                 F    [         R                  " U [        S5      X5        g )Ninf)r   __init__float)r   ttltimers      r   r-   _UnboundTTLCache.__init__*   s    dE%L#5r    c                     g r   r!   r   s    r   r   _UnboundTTLCache.maxsize-   s    r    r!   N)r"   r#   r$   r%   r-   r&   r   r'   r!   r    r   r)   r)   (   s    6  r    r)   Fc                    ^ ^ U U4S jnU$ )Nc                 $  >^ ^^^ T(       a  [         R                  O[         R                  m[        5       mSS/mUUU4S jnUUU4S jnUU UUU4S jn[        R
                  " UT 5        [        US5      (       d  T Ul        Xl        X#l	        U$ )Nr   c                     > T   Tu  pTR                   nTR                  nS S S 5        [        W WWW5      $ ! , (       d  f       N= fr   )r   r   
_CacheInfo)r   r   r   r   cachelockstatss       r   
cache_info-_cache.<locals>.decorator.<locals>.cache_info9   s?    -->>  fgx88	 4s	   7
Ac                     > T    T R                  5         SS/TS S &  S S S 5        g ! SS/TS S & f = f! , (       d  f       g = f)Nr   )clear)r8   r9   r:   s   r   cache_clear._cache.<locals>.decorator.<locals>.cache_clear@   sA    	
++-V%(	 4 V%(	 4s   3'3	03
Ac                  B  > T" U 0 UD6nT    TU   nTS==   S-  ss'   UsS S S 5        $ ! [          a    TS==   S-  ss'    Of = f S S S 5        O! , (       d  f       O= fT" U 0 UD6n T   UTU'   S S S 5        U$ ! , (       d  f       U$ = f! [         a     U$ f = f)Nr   r   )KeyError
ValueError)	argskwargskvr8   funckeyr9   r:   s	       r   wrapper*_cache.<locals>.decorator.<locals>.wrapperG   s    
t
v
a	Ah!
(a-(	 4
  	
(a-(	
 44 

a%(  h	 T h  hsV   A+AAAA
A ,B .A>4B >
BB B 
BB__wrapped__)
r   typedkeyhashkeyr   	functoolsupdate_wrapperhasattrrL   r;   r?   )	rH   r;   r?   rJ   rI   r9   r:   r8   typeds	   `   @@@r   	decorator_cache.<locals>.decorator4   sp     $--dllC7DFE9 " Wd+7M** g#%Nr    r!   )r8   rR   rS   s   `` r   _cacherU   2   s    )V 
r       c                 Z    U c  [        [        5       U5      $ [        [        U 5      U5      $ )zDecorator to wrap a function with a memoizing callable that saves

up to `maxsize` results based on a Least Frequently Used (LFU)
algorithm.

)rU   r   r	   r   rR   s     r   r   r   b   *     _-/5))(7#U++r    c                 Z    U c  [        [        5       U5      $ [        [        U 5      U5      $ )zDecorator to wrap a function with a memoizing callable that saves

up to `maxsize` results based on a Least Recently Used (LRU)
algorithm.

)rU   r   r
   rX   s     r   r   r   o   rY   r    c                 Z    U c  [        [        5       U5      $ [        [        X5      U5      $ )zDecorator to wrap a function with a memoizing callable that saves

up to `maxsize` results based on a Random Replacement (RR)
algorithm.

)rU   r   r   )r   choicerR   s      r   r   r   |   s*     _-/5))''*E22r    iX  c                 ^    U c  [        [        X5      U5      $ [        [        XU5      U5      $ )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.
)rU   r)   r   )r   r/   r0   rR   s       r   r   r      s0     _"3.66(7/77r    )F)rV   F)#__doc__
__future__r   collectionsrO   randomr   r   default_timerImportError	threadingr   dummy_threading r   lfur	   lrur
   rrr   r/   r   __all__
namedtupler7   dictr   r)   rU   r   r   r\   r   r   r!   r    r   <module>rm      s    E &   )-$     
=##K$MO
D x -`
,
, e 
3 s-u 	8}  )()
  $#$s"   B B+ B('B(+B:9B: