Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
idna / lib / python2.7 / site-packages / repoze / lru / __init__.pyc
Size: Mime:
ó
ԍEYc@€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((sH/home/tvault/.virtenv/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((sH/home/tvault/.virtenv/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((sH/home/tvault/.virtenv/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((sH/home/tvault/.virtenv/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((sH/home/tvault/.virtenv/lib/python2.7/site-packages/repoze/lru/__init__.pyt
invalidatezsN(	t__name__t
__module__t__doc__RRR
RR&R'(((sH/home/tvault/.virtenv/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,((sH/home/tvault/.virtenv/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((sH/home/tvault/.virtenv/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((sH/home/tvault/.virtenv/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%((sH/home/tvault/.virtenv/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((sH/home/tvault/.virtenv/lib/python2.7/site-packages/repoze/lru/__init__.pyR'sN(
R(R)R*t_DEFAULT_TIMEOUTRRR
RR&R'(((sH/home/tvault/.virtenv/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/((sH/home/tvault/.virtenv/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(sH/home/tvault/.virtenv/lib/python2.7/site-packages/repoze/lru/__init__.pyt
lru_cacheds
(R2RR)R(R*(RR5R7((R2R5R6sH/home/tvault/.virtenv/lib/python2.7/site-packages/repoze/lru/__init__.pyt__call__s	N(R(R)R*R
RR8(((sH/home/tvault/.virtenv/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/((sH/home/tvault/.virtenv/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/((sH/home/tvault/.virtenv/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((sH/home/tvault/.virtenv/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((sH/home/tvault/.virtenv/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@((sH/home/tvault/.virtenv/lib/python2.7/site-packages/repoze/lru/__init__.pyRgs
N(
R(R)R*R
R0RRARCRDR(((sH/home/tvault/.virtenv/lib/python2.7/site-packages/repoze/lru/__init__.pyR9(sI(
R*t
__future__RRR-R>tobjectRR0RR+R1R9(((sH/home/tvault/.virtenv/lib/python2.7/site-packages/repoze/lru/__init__.pyt<module>s	v†