%PDF- %PDF-
Direktori : /usr/lib/python2.7/site-packages/salt/cache/ |
Current File : //usr/lib/python2.7/site-packages/salt/cache/__init__.pyc |
� ���^c @@ s� d Z d d l m Z m Z m Z d d l Z d d l Z d d l Z d d l m Z d d l m Z d d l m Z d d l Z d d l Z e j e � Z d � Z d e f d � � YZ d e f d � � YZ d S( u\ Loader mechanism for caching data, with data expiration, etc. .. versionadded:: 2016.11.0 i ( t absolute_importt print_functiont unicode_literalsN( t six( t Serial( t OrderedDictc K@ s. | j d d � r t } n t } | | | � 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. u memcache_expire_secondsi ( t gett MemCachet Cache( t optst kwargst cls( ( s7 /usr/lib/python2.7/site-packages/salt/cache/__init__.pyt factory s R c B@ sz e Z d Z d d � Z d � Z e d � � Z d d � Z d � Z d � Z d � Z d d � Z d � Z d d � Z RS( 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. c K@ s� | | _ | d k r3 | j d t j j � | _ n | | _ | j d t j j d � | _ t | � | _ d | _ | | _ | j | j d <d S( Nu cachediru cache( R t NoneR t saltt syspathst CACHE_DIRt cachedirt configt DEFAULT_MASTER_OPTSt driverR t serialt _modulest _kwargs( t selfR R R ( ( s7 /usr/lib/python2.7/site-packages/salt/cache/__init__.pyt __init__F s c C@ sh t j j | j | j � | _ d j | j � } | | j k r[ | j | | j � | _ n i | _ d S( Nu {0}.init_kwargs( R t loadert cacheR R R t formatR t modulesR ( R t fun( ( s7 /usr/lib/python2.7/site-packages/salt/cache/__init__.pyt __lazy_initR s c C@ s# | j d k r | j � n | j S( N( R R t _Cache__lazy_init( R ( ( s7 /usr/lib/python2.7/site-packages/salt/cache/__init__.pyR Z s c K@ s� | j d d � } | j | | � } t } | d k r? t } n% t t j � � | | k rd t } n | j | | � } | s� | t k r� | d k 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. u expirei�Q N( R t updatedt FalseR t Truet intt timet fetcht appendt store( R t bankt keyR t loop_funR t expire_secondsR! t update_cachet datat itemst item( ( s7 /usr/lib/python2.7/site-packages/salt/cache/__init__.pyR ` s"