%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/utils/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/utils/memcached.pyc

�
���^c@@sdZddlmZmZddlZddlmZmZddlm	Z	ddl
mZyddlZe
ZWnek
r�eZnXdZdZdZdZeje�Zid	d
6Zd�Zdddd�Zd
�Zeed�Zd�ZdS(u�
Utilities for working with memcache

:depends:  - python-memcached

This library sets up a connection object for memcache, using the configuration
passed into the get_conn() function. Normally, this is __opts__. Optionally,
a profile or specific host and port may be passed in. If neither profile nor
host and port are provided, the defaults of '`127.0.0.`` and ``11211`` are
used. The following configurations are both valid:

.. code-block:: yaml

    # No profile name
    memcached.host: 127.0.0.1
    memcached.port: 11211

    # One or more profiles defined
    my_memcached_config:
      memcached.host: 127.0.0.1
      memcached.port: 11211

Once configured, the get_conn() function is passed a set of opts, and,
optionally, the name of a profile to be used.

.. code-block:: python

    import salt.utils.memcached_utils.py
    conn = salt.utils.memcached_utils.get_conn(__opts__,
                                              profile='my_memcached_config')

It should be noted that some usages of memcached may require a profile to be
specified, rather than top-level configurations. This being the case, it is
better to always use a named configuration profile, as shown above.
i(tabsolute_importtunicode_literalsN(tCommandExecutionErrortSaltInvocationError(t
integer_types(tsixu	127.0.0.1i�+usetuset_cC@str
tStS(u4
    Only load if python-memcached is installed
    (tHAS_LIBStTruetFalse(((s8/usr/lib/python2.7/site-packages/salt/utils/memcached.pyt__virtual__FscC@s�|o	|s�|jdi�}|jdi�}i}|j|�|j|�|j|�|rx|j|i�}n|}|jdt�}|jdt�}ntj|�j�s�td��ntr�t	j
dj||�g�Std��dS(	u6
    Return a conn object for accessing memcached
    upillarumasterumemcached.hostumemcached.portuport must be an integeru{0}:{1}u=(unable to import memcache, module most likely not installed)N(
tgettupdatetDEFAULT_HOSTtDEFAULT_PORTRt	text_typetisdigitRRtmemcachetClienttformatR(toptstprofilethosttporttopts_pillartopts_mastertopts_mergedtconf((s8/usr/lib/python2.7/site-packages/salt/utils/memcached.pytget_connMs$


cC@s%|j�}|s!td��n|S(u�
    Helper function to check the stats data passed into it, and raise an
    exception if none are returned. Otherwise, the stats are returned.
    u*memcached server is down or does not exist(t	get_statsR(tconntstats((s8/usr/lib/python2.7/site-packages/salt/utils/memcached.pyt_check_statsns
cC@s\t|t�std��nt|t�s<td��nt|�|j||||�S(uP
    Set a key on the memcached server, overwriting the value if it exists.
    u'time' must be an integeru%'min_compress_len' must be an integer(t
isinstanceRRRtset(Rtkeytvaluettimetmin_compress_len((s8/usr/lib/python2.7/site-packages/salt/utils/memcached.pytset_{s
cC@st|�|j|�S(u"
    Retrieve value for a key
    (RR
(RR"((s8/usr/lib/python2.7/site-packages/salt/utils/memcached.pyR
�s
(t__doc__t
__future__RRtloggingtsalt.exceptionsRRtsalt.ext.sixRtsalt.extRRRRtImportErrorRRR
tDEFAULT_TIMEtDEFAULT_MIN_COMPRESS_LENt	getLoggert__name__tlogt__func_alias__R	tNoneRRR&R
(((s8/usr/lib/python2.7/site-packages/salt/utils/memcached.pyt<module>$s.



	!	

Zerion Mini Shell 1.0