%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/cache/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/cache/__init__.pyo

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddl	m
Z
ddlmZddl
mZddlZddlZeje�Zd�Zdefd	��YZd
efd��YZdS(u\
Loader mechanism for caching data, with data expiration, etc.

.. versionadded:: 2016.11.0
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(tSerial(tOrderedDictcK@s.|jdd�rt}nt}|||�S(u�
    Creates and returns the cache class.
    If memory caching is enabled by opts MemCache class will be instantiated.
    If not Cache class will be returned.
    umemcache_expire_secondsi(tgettMemCachetCache(toptstkwargstcls((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pytfactorys	RcB@szeZdZdd�Zd�Zed��Zdd�Zd�Z	d�Z
d�Zdd�Zd	�Z
dd
�ZRS(u�
    Base caching object providing access to the modular cache subsystem.

    Related configuration options:

    :param cache:
        The name of the cache driver to use. This is the name of the python
        module of the `salt.cache` package. Default is `localfs`.

    :param serial:
        The module of `salt.serializers` package that should be used by the cache
        driver to store data.
        If a driver can't use a specific module or uses specific objects storage
        it can ignore this parameter.

    Terminology.

    Salt cache subsystem is organized as a tree with nodes and leafs like a
    filesystem. Cache consists of banks. Each bank can contain a number of
    keys. Each key can contain a dict or any other object serializable with
    `salt.payload.Serial`. I.e. any data object in the cache can be
    addressed by the path to the bank and the key name:
        bank: 'minions/alpha'
        key:  'data'

    Bank names should be formatted in a way that can be used as a
    directory structure. If slashes are included in the name, then they
    refer to a nested structure.

    Key name is a string identifier of a data container (like a file inside a
    directory) which will hold the data.
    cK@s�||_|dkr3|jdtjj�|_n	||_|jdtjjd�|_	t
|�|_d|_||_
|j|j
d<dS(Nucachedirucache(R	tNoneRtsalttsyspathst	CACHE_DIRtcachedirtconfigtDEFAULT_MASTER_OPTStdriverRtserialt_modulest_kwargs(tselfR	RR
((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pyt__init__Fs				cC@shtjj|j|j�|_dj|j�}||jkr[|j||j	�|_	n	i|_	dS(Nu{0}.init_kwargs(
RtloadertcacheR	RRtformatRtmodulesR(Rtfun((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pyt__lazy_initRs
cC@s#|jdkr|j�n|jS(N(RR
t_Cache__lazy_init(R((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pyRZs
cK@s�|jdd�}|j||�}t}|dkr?t}n%ttj��||krdt}n|j||�}	|	s�|tkr�|dk	r�g}	||�}
x0|
D]}|	j||��q�Wn||�}	|j	|||	�n|	S(uI
        Check cache for the data. If it is there, check to see if it needs to
        be refreshed.

        If the data is not there, or it needs to be refreshed, then call the
        callback function (``fun``) with any given ``**kwargs``.

        In some cases, the callback function returns a list of objects which
        need to be processed by a second function. If that is the case, then
        the second function is passed in as ``loop_fun``. Each item in the
        return list from the first function will be the only argument for the
        second function.
        uexpirei�QN(
RtupdatedtFalseR
tTruetintttimetfetchtappendtstore(RtbanktkeyRtloop_funR
texpire_secondsR!tupdate_cachetdatatitemstitem((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pyR`s"		
cC@s/dj|j�}|j|||||j�S(u�
        Store data using the specified module

        :param bank:
            The name of the location inside the cache which will hold the key
            and its associated data.

        :param key:
            The name of the key (or file inside a directory) which will hold
            the data. File extensions should not be provided, as they will be
            added by the driver itself.

        :param data:
            The data which will be stored in the cache. This data should be
            in a format which can be serialized by msgpack/json/yaml/etc.

        :raises SaltCacheError:
            Raises an exception if cache driver detected an error accessing data
            in the cache backend (auth, permissions, etc).
        u	{0}.store(RRRR(RR)R*R.R((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pyR(�scC@s,dj|j�}|j||||j�S(u�
        Fetch data using the specified module

        :param bank:
            The name of the location inside the cache which will hold the key
            and its associated data.

        :param key:
            The name of the key (or file inside a directory) which will hold
            the data. File extensions should not be provided, as they will be
            added by the driver itself.

        :return:
            Return a python object fetched from the cache or an empty dict if
            the given path or key not found.

        :raises SaltCacheError:
            Raises an exception if cache driver detected an error accessing data
            in the cache backend (auth, permissions, etc).
        u	{0}.fetch(RRRR(RR)R*R((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pyR&�scC@s,dj|j�}|j||||j�S(u�
        Get the last updated epoch for the specified key

        :param bank:
            The name of the location inside the cache which will hold the key
            and its associated data.

        :param key:
            The name of the key (or file inside a directory) which will hold
            the data. File extensions should not be provided, as they will be
            added by the driver itself.

        :return:
            Return an int epoch time in seconds or None if the object wasn't
            found in cache.

        :raises SaltCacheError:
            Raises an exception if cache driver detected an error accessing data
            in the cache backend (auth, permissions, etc).
        u{0}.updated(RRRR(RR)R*R((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pyR!�scC@s/dj|j�}|j||d||j�S(u�
        Remove the key from the cache bank with all the key content. If no key is specified remove
        the entire bank with all keys and sub-banks inside.

        :param bank:
            The name of the location inside the cache which will hold the key
            and its associated data.

        :param key:
            The name of the key (or file inside a directory) which will hold
            the data. File extensions should not be provided, as they will be
            added by the driver itself.

        :raises SaltCacheError:
            Raises an exception if cache driver detected an error accessing data
            in the cache backend (auth, permissions, etc).
        u	{0}.flushR*(RRRR(RR)R*R((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pytflush�scC@s)dj|j�}|j|||j�S(u
        Lists entries stored in the specified bank.

        :param bank:
            The name of the location inside the cache which will hold the key
            and its associated data.

        :return:
            An iterable object containing all bank entries. Returns an empty
            iterator if the bank doesn't exists.

        :raises SaltCacheError:
            Raises an exception if cache driver detected an error accessing data
            in the cache backend (auth, permissions, etc).
        u{0}.list(RRRR(RR)R((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pytlist�scC@s,dj|j�}|j||||j�S(u	
        Checks if the specified bank contains the specified key.

        :param bank:
            The name of the location inside the cache which will hold the key
            and its associated data.

        :param key:
            The name of the key (or file inside a directory) which will hold
            the data. File extensions should not be provided, as they will be
            added by the driver itself.

        :return:
            Returns True if the specified key exists in the given bank and False
            if not.
            If key is None checks for the bank existense.

        :raises SaltCacheError:
            Raises an exception if cache driver detected an error accessing data
            in the cache backend (auth, permissions, etc).
        u{0}.contains(RRRR(RR)R*R((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pytcontains�sN(t__name__t
__module__t__doc__R
RR tpropertyRRR(R&R!R1R2R3(((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pyR%s 	&				RcB@sbeZdZiZd�Zed��Zd�Zed��Z	d�Z
d�Zdd�Z
RS(	ua
    Short-lived in-memory cache store keeping values on time and/or size (count)
    basis.
    cK@s�tt|�j||�|jdd�|_|jdd�|_|jdt�|_|jdt�|_|jr�d|_	d|_
nd|_dS(Numemcache_expire_secondsi
umemcache_max_itemsiumemcache_full_cleanupumemcache_debugi(
tsuperRRRtexpiretmaxR"tcleanuptdebugtcallthitR
t_storage(RR	R
((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pyRs		cC@sotj�}x\tj|j�D]H}x?t|j��D]+\}}|d||krb||=q8Pq8WqWdS(Ni(R%Rt
itervaluesR.R2R/(RR9tnowtstorageR*R.((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pyt	__cleanup#s
cC@s@dj|j�}||jkr5|j||j�S|jSdS(Nu{0}.storage_id(RRRR
(RR((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pyt_get_storage_id-scC@sW|jdkrP|j�}|tjkr=t�tj|<ntj||_n|jS(N(R?R
RDRR.R(Rt
storage_id((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pyRB4scC@sn|jr|jd7_ntj�}|jj||fd�}|dk	r�|d|j|kr�|jr�|jd7_tjd|j|jt	|j�|j�n||d<||j||f<|dSt
t|�j||�}t
|j�|jkrQ|jr tj|j�nt
|j�|jkrQ|jjdt�qQn||g|j||f<|S(Niiu(MemCache stats (call/hit/rate): %s/%s/%stlast(R<R=R%RBtpopR
R9R>tlogtfloatR8RR&tlenR:R;t_MemCache__cleanuptpopitemR"(RR)R*RAtrecordR.((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pyR&=s*	#	&
	cC@s�|jj||fd�tt|�j|||�t|j�|jkr�|jritj	|j
�nt|j�|jkr�|jjdt�q�nt
j
�|g|j||f<dS(NRF(RBRGR
R8RR(RJR:R;RKR9RLR"R%(RR)R*R.((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pyR(Ys	cC@s6|jj||fd�tt|�j||�dS(N(RBRGR
R8RR1(RR)R*((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pyR1csN(R4R5R6R.RtclassmethodRKRDR7RBR&R(R
R1(((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pyRs	
				
(R6t
__future__RRRtloggingR%tsalt.configRtsalt.extRtsalt.payloadRtsalt.utils.odictRtsalt.loadert
salt.syspathst	getLoggerR4RHRtobjectRR(((s7/usr/lib/python2.7/site-packages/salt/cache/__init__.pyt<module>s	
�

Zerion Mini Shell 1.0