%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/
Upload File :
Create Path :
Current File : //proc/self/root/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pyo

�
��Oc@�s�dZddlmZddlZddlZddlZe�ZdZdefd��YZ	defd	��YZ
d
efd��YZdefd
��YZdS(s! LRU caching class and decorator i����(twith_statementNii<tLRUCachecB�s>eZdZd�Zd�Zdd�Zd�Zd�ZRS(s� Implements a pseudo-LRU algorithm (CLOCK)

    The Clock algorithm is not kept strictly to improve performance, e.g. to
    allow get() and invalidate() to work without acquiring the lock.
    cC�s�t|�}|dkr'td��n||_tj�|_d|_|d|_d|_	d|_
d|_d|_d|_
d|_d|_|j�dS(Nissize must be >0i(tintt
ValueErrortsizet	threadingtLocktlockthandtmaxpostNonet
clock_keyst
clock_refstdatat	evictionsthitstmissestlookupstclear(tselfR((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pyt__init__s		
							cC�ss|j�di|_|j}tg||_tg||_d|_d|_d|_	d|_
d|_WdQXdS(s!Remove all entries from the cacheiN(RR
Rt_MARKERRtFalseRRRRRR(RR((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pyR&s
						cC�sj|jd7_y&|j|\}}|jd7_Wn!tk
rX|jd7_|SXt|j|<|S(s5Return value for key. If not in cache, return defaulti(RR
RtKeyErrorRtTrueR(Rtkeytdefaulttpostval((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pytget9s

cC�s�|j}|j}|j}|j}|j�d|j|�}|dk	r�|\}}	|	|k	rt||f||<nt|j|<dS|j}
d}d}x�||
}
|
tkrt	||
<|
d7}
|
|kr�d}
n|d7}||kr�t	||
<q�q�||
}|j
|t�}|tk	r<|jd7_n|||
<t||
<|
|f||<|
d7}
|
|krd}
n|
|_Pq�WWdQXdS(s#Add key to the cache with value valNiiki(
R	RRR
RRR
RRRtpopRR(RRRR	RRR
tentryRtold_valRtcountt	max_counttreftoldkeytoldentry((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pytputEsJ				

	


	




		cC�s9|jj|t�}|tk	r5t|j|d<ndS(sRemove key from the cacheiN(R
RRRR(RRR((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pyt
invalidatezsN(	t__name__t
__module__t__doc__RRR
RR&R'(((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pyRs			5tExpiringLRUCachecB�sDeZdZed�Zd�Zdd�Zdd�Zd�Z	RS(s� Implements a pseudo-LRU algorithm (CLOCK) with expiration times

    The Clock algorithm is not kept strictly to improve performance, e.g. to
    allow get() and invalidate() to work without acquiring the lock.
    cC�s�||_t|�}|dkr0td��n||_tj�|_d|_|d|_d|_
d|_d|_d|_
d|_d|_d|_|j�dS(Nissize must be >0i(tdefault_timeoutRRRRRRRR	R
RRR
RRRRR(RRR,((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pyR�s 			
							cC�ss|j�di|_|j}tg||_tg||_d|_d|_d|_	d|_
d|_WdQXdS(s!Remove all entries from the cacheiN(RR
RRRRRRRRRR(RR((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pyR�s
						cC�s�|jd7_y|j|\}}}Wn!tk
rL|jd7_|SX|tj�kr|jd7_t|j|<|S|jd7_t|j|<|SdS(s@Return value for key. If not in cache or expired, return defaultiN(	RR
RRttimeRRRR(RRRRRtexpires((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pyR�s


cC�s�|j}|j}|j}|j}|j}|dkrE|j}n|j�j|j|�}	|	dk	r�|	d}
|
|tj�|f||<t	||
<dS|j
}d}d}
x�||}|t	krt||<|d7}||kr�d}n|d7}||
kr�t||<q�q�||}|j|t
�}|t
k	rV|jd7_n|||<t	||<||tj�|f||<|d7}||kr�d}n||_
Pq�WWdQXdS(s�Add key to the cache with value val

        key will expire in $timeout seconds. If key is already in cache, val
        and timeout will be updated.
        iNiki(R	RRR
RR
R,RR-RRRRRR(RRRttimeoutR	RRR
RRRRR!R"R#R$R%((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pyR&�sN					


	


	




		cC�s9|jj|t�}|tk	r5t|j|d<ndS(sRemove key from the cacheiN(R
RRRR(RRR((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pyR'sN(
R(R)R*t_DEFAULT_TIMEOUTRRR
RR&R'(((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pyR+�s	;t	lru_cachecB�s&eZdZddd�Zd�ZRS(s� Decorator for LRU-cached function

    timeout parameter specifies after how many seconds a cached entry should
    be considered invalid.
    cC�sI|dkr<|dkr't|�}q<t|d|�}n||_dS(NR,(R
RR+tcache(RtmaxsizeR2R/((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pyRs
c�sL|j�t����fd�}�j|_�j|_�j|_|S(Nc�sA�j|��}|�kr=�|�}�j||�n|S(N(RR&(targR(R2tftmarker(sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pyt
lru_cacheds
(R2RR)R(R*(RR5R7((R2R5R6sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pyt__call__s	N(R(R)R*R
RR8(((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pyR1st
CacheMakercB�sYeZdZded�Zdddd�Zddd�Zdddd�Zd�Z	RS(s3Generates decorators that can be cleared later
    cC�s||_||_i|_dS(s�Create cache decorator factory.

        - maxsize : the default size for created caches.

        - timeout : the defaut expiraiton time for created caches.
        N(t_maxsizet_timeoutt_cache(RR3R/((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pyR+s		cC�s�|dkrAx2tr=ttj��}||jkrPqqWn||jkrctd|��n|dkr{|j}n|dkr�td��n|dkr�|j	}n|||fS(Nscache %s already in usesCache must have a maxsize set(
R
Rtstrtuuidtuuid4R<RR:RR;(RtnameR3R/((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pyt_resolve_setting6s	cC�s?|j||�\}}}t|�}|j|<t||�S(s�Named arguments:
        
        - name (optional) is a string, and should be unique amongst all caches

        - maxsize (optional) is an int, overriding any default value set by
          the constructor
        (RARR<R1(RR@R3t_R2((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pytlrucacheLscC�sPdt|j|||�\}}}t||�}|j|<t|||�S(Ns[Named arguments:

        - name (optional) is a string, and should be unique amongst all caches

        - maxsize (optional) is an int, overriding any default value set by
          the constructor

        - timeout (optional) is an int, overriding any default value set by
          the constructor or the default value (%d seconds)  
        (R0RAR+R<R1(RR@R3R/R2((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pytexpiring_lrucacheXs
cG�sJt|�dkr$|jj�}nx|D]}|j|j�q+WdS(s_Clear the given cache(s).
        
        If no 'names' are passed, clear all caches.
        iN(tlenR<tkeysR(RtnamesR@((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pyRgs
N(
R(R)R*R
R0RRARCRDR(((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pyR9(sI(
R*t
__future__RRR-R>tobjectRR0RR+R1R9(((sD/opt/alt/python27/lib/python2.7/site-packages/repoze/lru/__init__.pyt<module>s	v�

Zerion Mini Shell 1.0