File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/memcached.cpython-310.pyc
Back
o ;j\ � @ s6 d Z ddlZddlZddlmZmZ zddlZdZW n e y% dZY nw dZ dZdZdZ e�e�Zdd iZd Zdd� Ze efd d�Zdd� Ze efdd�Ze efdd�Ze eee fdd�Ze eefdd�Ze eee fdd�Ze eee fdd�Zde efdd�Zejj�ed�Z de efd d!�Z!ejj�e!d"�Z"dS )#zE Module for Management of Memcached Keys .. versionadded:: 2014.1.0 � N)�CommandExecutionError�SaltInvocationErrorTFz 127.0.0.1i�+ �set_�setZ memcachedc C s t rtS dS )z3 Only load if python-memcache is installed )FzWThe memcached execution module cannot be loaded: python memcache library not available.)�HAS_MEMCACHE�__virtualname__� r r �J/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/memcached.py�__virtual__# s r c C s. t |��� rtj| � d|� �gdd�S td��)zv Returns a tuple of (user, host, port) with config, pillar, or default values assigned to missing values. �:r )�debugzport must be an integer)�str�isdigit�memcacheZClientr )�host�portr r r �_connect0 s r c C s | � � }|s td��|S )z� Helper function to check the stats data passed into it, and raise an exception if none are returned. Otherwise, the stats are returned. z*memcached server is down or does not exist)� get_statsr )�conn�statsr r r �_check_stats: s r c C sD t | |�}zt|�d }W n ttfy Y dS w |d |d iS )zm Get memcached status CLI Example: .. code-block:: bash salt '*' memcached.status r F� )r r r � IndexError)r r r r r r r �statusE s �r c C s t ||�}t|� |�| �S )zt Retrieve value for a key CLI Example: .. code-block:: bash salt '*' memcached.get <key> )r r �get)�keyr r r r r r r X s r c C sF t |t�s td��t |t�std��t||�}t|� |�| |||�S )z� Set a key on the memcached server, overwriting the value if it exists. CLI Example: .. code-block:: bash salt '*' memcached.set <key> <value> �'time' must be an integer�%'min_compress_len' must be an integer)� isinstance�intr r r r �r �valuer r �time�min_compress_lenr r r r r g s c C s4 t |t�s td��t||�}t|� t|�| |��S )z� Delete a key from memcache server CLI Example: .. code-block:: bash salt '*' memcached.delete <key> r )r r r r r �bool�delete)r r r r"