Your IP : 216.73.216.85


Current Path : /opt/alt/python27/lib/python2.7/site-packages/py/_path/
Upload File :
Current File : //opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyc

�
%q�]c@s�dZddlmZdefd��YZdefd��YZdefd��YZd	efd
��YZdefd��YZd
S(s�
This module contains multithread-safe cache implementations.

All Caches have

    getorbuild(key, builder)
    delentry(key)

methods and allow configuration when instantiating the cache class.
i����(ttimet
BasicCachecBsMeZdd�Zd�Zd�Zd�Zed�Zd�Zd�Z	RS(i�cCs-||_t||d�|_i|_dS(Ni(t
maxentriestinttprunenumt_dict(tselfR((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyt__init__s	cCs|jj�dS(N(Rtclear(R((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyRscCs|j|S(N(R(Rtkey((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyt	_getentryscCs|j�||j|<dS(N(t_prunelowestweightR(RR	tentry((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyt	_putentrys
cCs2y|j|=Wntk
r-|r.�q.nXdS(N(RtKeyError(RR	traising((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pytdelentrys

cCsPy|j|�}Wn3tk
rH|j||�}|j||�nX|jS(N(R
Rt_buildR
tvalue(RR	tbuilderR((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyt
getorbuild$s
cCs�t|j�}||jkr�g|jj�D]\}}|j|f^q.}|j�||j}|dkr�x.|| D]\}}|j|dt�q}Wq�ndS(s' prune out entries with lowest weight. iRN(	tlenRRtitemstweighttsortRRtFalse(Rt
numentriesR	RRtindexR((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyR,s.

(
t__name__t
__module__RRR
R
RRRR(((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyR
s				tBuildcostAccessCachecBseZdZd�ZRS(s� A BuildTime/Access-counting cache implementation.
        the weight of a value is computed as the product of

            num-accesses-of-a-value * time-to-build-the-value

        The values with the least such weights are evicted
        if the cache maxentries threshold is superceded.
        For implementation flexibility more than one object
        might be evicted at a time.
    cCs,t�}|�}t�}t|||�S(N(tgettimetWeightedCountingEntry(RR	Rtstarttvaltend((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyRGs			(RRt__doc__R(((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyR:s
R cBs&eZd�Zd�Zee�ZRS(cCs||_||_|_dS(N(t_valueRt
_oneweight(RRt	oneweight((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyROs	cCs|j|j7_|jS(N(RR&R%(R((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyRSs(RRRRtproperty(((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyR Ns		t
AgingCachecBs/eZdZddd�Zd�Zd�ZRS(s; This cache prunes out cache entries that are too old.
    i�g$@cCs#tt|�j|�||_dS(N(tsuperR)Rt
maxseconds(RRR+((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyR[scCs9|j|}|j�r5|j|�t|��n|S(N(Rt	isexpiredRR(RR	R((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyR
_s


cCs&|�}t|t�|j�}|S(N(t
AgingEntryRR+(RR	RR"R((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyRfs	(RRR$RR
R(((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyR)Xs	R-cBseZd�Zd�ZRS(cCs||_||_dS(N(RR(RRtexpirationtime((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyRls	cCst�}||jkS(N(RR(Rtt((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyR,ps	(RRRR,(((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyR-ks	N(	R$RRtobjectRRR R)R-(((sC/opt/alt/python27/lib/python2.7/site-packages/py/_path/cacheutil.pyt<module>
s-