
    $                     R    S r SSKJr  SSKJr  SSKJr  SSKr " S S5      rS	S jrg)
z3Utilities for caching the result of function calls.    )absolute_import)division)unicode_literalsNc                   *    \ rS rSrSrS rS rS rSrg)FakeLruCache   z>Doesn't actually cache but supports LRU interface in Python 2.c                     Xl         g N	_function)selffunctions     6lib/googlecloudsdk/core/cache/function_result_cache.py__init__FakeLruCache.__init__   s    N    c                     g)zFExposes this function of actual LRU to avoid missing attribute errors.N )r   s    r   cache_clearFakeLruCache.cache_clear   s    r   c                 &    U R                   " U0 UD6$ r
   r   )r   argskwargss      r   __call__FakeLruCache.__call__"   s    >>4*6**r   r   N)	__name__
__module____qualname____firstlineno____doc__r   r   r   __static_attributes__r   r   r   r   r      s    F	+r   r   c                    ^  U 4S jnU$ )a  Returns cached result if function was run with same args before.

Wraps functools.lru_cache, so it's not referenced at import in Python 2 and
unsupported Python 3 distributions.

Args:
  maxsize (int|None): From Python functools docs: "...saves up to the maxsize
    most recent calls... If maxsize is set to None, the LRU feature is
    disabled and the cache can grow without bound."

Returns:
  Wrapped functools.lru_cache.
c                 z   > [        [        SS 5      (       a  [        R                  " TS9" U 5      $ [        U 5      $ )N	lru_cache)maxsize)getattr	functoolsr$   r   )r   r%   s    r   _wrapperlru.<locals>._wrapper5   s3    y+t,,  1(;;!!r   r   )r%   r(   s   ` r   lrur*   &   s    "
 
/r   )   )r    
__future__r   r   r   r'   r   r*   r   r   r   <module>r-      s%    : &  ' + +r   