
    dyg                     J    d Z ddlmZ ddlmZ ddlmZ  edg d      Zd	dZy)
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	CacheInfo)hitsmissesmaxsizecurrsizec                       fd}|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

    c                 R   	
 t               ddgd\  j                  t        t               g }||d d g|d d  |gd\  	
rdkD  s
J dz         	
 fd}fd}fd} |_        ||_        ||_        t        |       S )Nr   )r      )r   r         zmaxsize %s not supportedc                     | }5   |      }|F\  }|\  }}}}||<   ||<   |   }|x|<   |<   ||<   ||<   
xx   dz  cc<   |cd d d        S 	 d d d         |  }5  \  }|v rnS       k\  r.|}||<   ||<   |   x}d<   |   }	d x|<   |<   |	= ||<   n|   }||||g}|x|<   x|<   |<   xx   dz  cc<   d d d        |S # 1 sw Y   xY w# 1 sw Y   |S xY w)Nr   r    )argskeylinkroot	link_prev	link_nextresultlastoldrootoldkeyHITSKEYMISSESNEXTPREVRESULT_lencache	cache_getlockr	   nonlocal_rootstatsuser_functions             N/var/www/html/webapps/venv/lib/python3.12/site-packages/psycopg2/_lru_cache.pywrapperz7lru_cache.<locals>.decorating_function.<locals>.wrapper&   s   C " ~# *ED8<5Iy#v&/IdO&/IdO:D.22DJd!%DJ!%DJ$K1$K!" "#" #D)F #%%<
 %[G+"G#&GCL&,GFO.5dm;D=+!#YF/33DIVf!(E#J  :D $V4D;??DJ?deCjf"5#6 MW" " #6 Ms   AC'A*C'C$'C1c            	      n    5  t               t                    cddd       S # 1 sw Y   yxY w)zReport cache statisticsN)
_CacheInfolen)r   r   r#   r%   r	   r'   s   r)   
cache_infoz:lru_cache.<locals>.decorating_function.<locals>.cache_infoV   s9     S!%+uV}gs5zRS S Ss   +4c                  ~    5  j                          d   } | | ddg| dd ddgdd ddd       y# 1 sw Y   yxY w)z$Clear the cache and cache statisticsr   N)clear)r   r#   r%   r&   r'   s    r)   cache_clearz;lru_cache.<locals>.decorating_function.<locals>.cache_clear[   sM     "$Q'tT2Qq6a	" " "s   &3<)dictgetr-   r   __wrapped__r.   r1   r   )r(   r   r*   r.   r1   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r	   s   `    @@@@@@@@@@@@r)   decorating_functionz&lru_cache.<locals>.decorating_function   s    AfII	wtT*Q",dC7Q;L(BW(LL&.	 .	 .	`	S 	S
	" ,')g}55    r   )r	   r5   s   ` r)   	lru_cacher7      s    O6b r6   N)d   )	__doc__collectionsr   	functoolsr   	threadingr   r,   r7   r   r6   r)   <module>r=      s(    # $ %NO
Yr6   