-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /usr/lib/python2.7/dist-packages/bzrlib/
File Upload :
Current File : //usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyc

ó
î:ïNc@@s{dZddlmZddlmZmZeƒZdefd„ƒYZdefd„ƒYZ	de	fd	„ƒYZ
d
S(s)A simple least-recently-used (LRU) cache.i(tabsolute_import(tsymbol_versioningttracet_LRUNodecB@s&eZdZdZd„Zd„ZRS(s:This maintains the linked-list which is the lru internals.tprevtnext_keytkeytvaluecC@s(d|_t|_||_||_dS(N(tNoneRt	_null_keyRRR(tselfRR((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyt__init__!s			cC@sD|jdkrd}n|jj}d|jj|j|j|fS(Ns%s(%r n:%r p:%r)(RRRt	__class__t__name__R(R
tprev_key((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyt__repr__'s
	(sprevsnext_keyskeysvalue(R
t
__module__t__doc__t	__slots__RR(((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyRs	tLRUCachecB@sïeZdZddd„Zd„Zd„Zd„Zej	ej
dƒƒdd	„ƒZd
„Zd„Z
dd„Zd
„Zd„Zej	ej
dƒƒeƒZd„Zd„Zd„Zd„Zd„Zdd„Zdd„ZRS(s?A class which manages a cache of entries, removing unused ones.idcC@s/i|_d|_d|_|j||ƒdS(N(t_cacheRt_most_recently_usedt_least_recently_usedt_update_max_cache(R
t	max_cachetafter_cleanup_count((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyR3s			cC@s
||jkS(N(R(R
R((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyt__contains__;scC@s£|j}||}|j}||kr/|jS|j}|j}|tkrY||_n||}||_||_|j|_||_||_d|_|jS(N(	RRRRRR	RRR(R
Rtcachetnodetmrut	node_prevRt	node_next((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyt__getitem__>s"	
			
					cC@s
t|jƒS(N(tlenR(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyt__len__]siiicC@s+|dk	rtdƒ‚n|j||ƒS(Ns.Per-node cleanup functions no longer supported(Rt
ValueErrort__setitem__(R
RRtcleanup((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pytadd`scC@s¢|tkrtdƒ‚n||jkrP|j|}||_|j|ƒn)t||ƒ}||j|<|j|ƒt|jƒ|jkrž|jƒndS(sAdd a new value to the cachescannot use _null_key as a keyN(	R	R#RRt_record_accessRR!t
_max_cacheR%(R
RRR((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyR$gs
	

cC@s|jS(s(Get the number of entries we will cache.(R((R
((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyt
cache_sizexscC@s9|jj|dƒ}|dkr%|S|j|ƒ|jS(N(RtgetRR'R(R
RtdefaultR((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyR*|s

cC@s
|jjƒS(sGet the list of keys currently cached.

        Note that values returned here may not be available by the time you
        request them later. This is simply meant as a peak into the current
        state.

        :return: An unordered list of keys that are currently cached.
        (Rtkeys(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyR,ƒs	cC@std„|jjƒDƒƒS(s9Get a new dict with the same key:value pairs as the cachecs@s$|]\}}||jfVqdS(N(R(t.0tktn((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pys	<genexpr>s(tdictRt	iteritems(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pytas_dictŽscC@s-x&t|jƒ|jkr(|jƒqWdS(s¯Clear the cache until it shrinks to the requested size.

        This does not completely wipe the cache, just makes sure it is under
        the after_cleanup_count.
        N(R!Rt_after_cleanup_countt_remove_lru(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyR%•scC@sÖ|jdkr%||_||_dS||jkr8dS||jkrV|j|_n|jdk	rw|j|j_n|jtk	r¥|j|j}|j|_n|jj|_||j_||_d|_dS(sRecord that key was accessed.N(RRRRRR	RR(R
RR((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyR'Ÿs"			cC@s±||jkr|j|_n|jj|jƒ|jdkrLd|_n|jdk	rm|j|j_n|jtk	r›|j|j}|j|_nd|_t|_dS(N(	RRRtpopRRRRR	(R
RR((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyt_remove_node¹s	cC@s|j|jƒdS(s¯Remove one entry from the lru, and handle consequences.

        If there are no more references to the lru, then this entry should be
        removed from the cache.
        N(R6R(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyR4ÉscC@sx|jr|jƒqWdS(sClear out all of the cache.N(RR4(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pytclearÑscC@s|j|d|ƒdS(s1Change the number of entries that will be cached.RN(R(R
RR((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pytresize×scC@sO||_|dkr,|jdd|_nt||jƒ|_|jƒdS(Nii
(R(RR3tminR%(R
RR((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyRÜs	N(iii(iii(R
RRRRRR R"Rtdeprecated_methodt
deprecated_inR&R$R)R*R,R2titemsR%R'R6R4R7R8R(((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyR0s,								
				tLRUSizeCachecB@sSeZdZdd	d	d„Zd„Zd„Zd„Zd	d„Zd	d„Z	RS(
sUAn LRUCache that removes things based on the size of the values.

    This differs in that it doesn't care how many actual items there are,
    it just restricts the cache to be cleaned up after so much data is stored.

    The size of items added will be computed using compute_size(value), which
    defaults to len() if not supplied.
    icC@sgd|_||_|dkr*t|_n|j|d|ƒtj|dtt|dƒdƒƒdS(s¥Create a new LRUSizeCache.

        :param max_size: The max number of bytes to store before we start
            clearing out entries.
        :param after_cleanup_size: After cleaning up, shrink everything to this
            size.
        :param compute_size: A function to compute the size of the values. We
            use a function here, so that you can pass 'len' if you are just
            using simple strings, or a more complex function if you are using
            something like a list of strings, or even a custom object.
            The function should take the form "compute_size(value) => integer".
            If not supplied, it defaults to 'len()'
        itafter_cleanup_sizeRiiN(	t_value_sizet
_compute_sizeRR!t_update_max_sizeRRtmaxtint(R
tmax_sizeR>tcompute_size((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyRðs		cC@s|tkrtdƒ‚n|jj|dƒ}|j|ƒ}||jkrtjd|||j|j	ƒ|dk	r‰|j
|ƒndS|dkr¸t||ƒ}||j|<n|j|j|j
ƒ8_|j|7_|j|ƒ|j|j	kr|jƒndS(sAdd a new value to the cachescannot use _null_key as a keysfAdding the key %r to an LRUSizeCache failed. value %d is too big to fit in a the cache with size %d %dN(R	R#RR*RR@t_after_cleanup_sizeRtmuttert	_max_sizeR6RR?RR'R%(R
RRRt	value_len((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyR$s&	
cC@s'x |j|jkr"|jƒqWdS(s®Clear the cache until it shrinks to the requested size.

        This does not completely wipe the cache, just makes sure it is under
        the after_cleanup_size.
        N(R?RFR4(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyR%#scC@s/|j|j|jƒ8_tj||ƒdS(N(R?R@RRR6(R
R((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyR6-scC@s=|j|d|ƒtt|dƒdƒ}|j|ƒdS(s/Change the number of bytes that will be cached.R>iiN(RARBRCR(R
RDR>R((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyR81scC@sE||_|dkr,|jdd|_nt||jƒ|_dS(Nii
(RHRRFR9(R
RDR>((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyRA7s	iN(
R
RRRRR$R%R6R8RA(((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyR=æs		
	N(Rt
__future__RtbzrlibRRtobjectR	RRR=(((s4/usr/lib/python2.7/dist-packages/bzrlib/lru_cache.pyt<module>s	¶

Copyright © 2017 || Recoded By Mr.Bumblebee