HEX
Server: LiteSpeed
System: Linux cpir1.prohostdns.com 4.18.0-553.123.2.lve.el8.x86_64 #1 SMP Thu May 7 23:17:13 UTC 2026 x86_64
User: pelakir (2976)
PHP: 8.2.31
Disabled: exec, shell_exec, system, passthru, proc_open, proc_close, proc_terminate, proc_get_status, popen, pclose, pcntl_exec
Upload Files
File: //usr/local/lib/python3.6/site-packages/bmemcached/client/__pycache__/replicating.cpython-36.pyc
3

�':f&�@s ddlmZGdd�de�ZdS)�)�ClientMixinc@s�eZdZdZdd�Zdd�Zd#dd	�Zd
d�Zd$dd
�Zd&dd�Z	d(dd�Z
d*dd�Zd,dd�Zd.dd�Z
d/dd�Zdd�Zd0dd �Zd1d!d"�ZdS)2�ReplicatingClientz�
    This is intended to be a client class which implement standard cache interface that common libs do...

    It replicates values over servers and get a response from the first one it can.
    cCsx|jD]}|j|�qWdS)N)�_serversZset_retry_delay)�self�value�server�r�P/tmp/pip-build-5ba02zx6/python-binary-memcached/bmemcached/client/replicating.py�_set_retry_delaysz"ReplicatingClient._set_retry_delaycCs|j|rdnd�dS)a�
        Enable or disable delaying between reconnection attempts.

        The first reconnection attempt will always happen immediately, so intermittent network
        errors don't cause caching to turn off.  The retry delay takes effect after the first
        reconnection fails.

        The reconnection delay is enabled by default for TCP connections, and disabled by
        default for Unix socket connections.
        �rN)r
)r�enablerrr	�enable_retry_delays
z$ReplicatingClient.enable_retry_delayNFcCsZx4|jD]*}|j|�\}}|dk	r|r.||fS|SqW|dk	rN|rJ|dfS|S|rVdSdS)a
        Get a key from server.

        :param key: Key's name
        :type key: six.string_types
        :param default: In case memcached does not find a key, return a default value
        :param get_cas: If true, return (value, cas), where cas is the new CAS value.
        :type get_cas: boolean
        :return: Returns a key data from server.
        :rtype: object
        N)NN)�servers�get)r�key�default�get_casrr�casrrr	rszReplicatingClient.getcCs2x,|jD]"}|j|�\}}|dk	r||fSqWdS)aL
        Get a key from server, returning the value and its CAS key.

        This method is for API compatibility with other implementations.

        :param key: Key's name
        :type key: six.string_types
        :return: Returns (key data, value), or (None, None) if the value is not in cache.
        :rtype: object
        N)NN)rr)rrrrrrrr	�gets8s
zReplicatingClient.getscsni�|rjx`|jD]V}|j|�}|sDx |j�D]\}\}}|||<q,W�j|��fdd�|D�}|sPqW�S)aH
        Get multiple keys from server.

        :param keys: A list of keys to from server.
        :type keys: list
        :param get_cas: If get_cas is true, each value is (data, cas), with each result's CAS value.
        :type get_cas: boolean
        :return: A dict with all requested keys.
        :rtype: dict
        csg|]}|�kr|�qSrr)�.0�_)�drr	�
<listcomp>]sz/ReplicatingClient.get_multi.<locals>.<listcomp>)r�	get_multi�items�update)r�keysrr�resultsrrrr)rr	rIs

zReplicatingClient.get_multir�cCs4g}x&|jD]}|j|j||||d��qWt|�S)a4
        Set a value for a key on server.

        :param key: Key's name
        :type key: str
        :param value: A value to be stored on server.
        :type value: object
        :param time: Time in seconds that your key will expire.
        :type time: int
        :param compress_level: How much to compress.
            0 = no compression, 1 = fastest, 9 = slowest but best,
            -1 = default compression level.
        :type compress_level: int
        :return: True in case of success and False in case of failure
        :rtype: bool
        )�compress_level)r�append�set�any)rrr�timer�returnsrrrr	r!bszReplicatingClient.setc	Cs6g}x(|jD]}|j|j|||||d��qWt|�S)a�
        Set a value for a key on server if its CAS value matches cas.

        :param key: Key's name
        :type key: six.string_types
        :param value: A value to be stored on server.
        :type value: object
        :param cas: The CAS value previously obtained from a call to get*.
        :type cas: int
        :param time: Time in seconds that your key will expire.
        :type time: int
        :param compress_level: How much to compress.
            0 = no compression, 1 = fastest, 9 = slowest but best,
            -1 = default compression level.
        :type compress_level: int
        :return: True in case of success and False in case of failure
        :rtype: bool
        )r)rr rr")rrrrr#rr$rrrr	ryszReplicatingClient.cascCs:t�}|r2x&|jD]}|t|j|||d��O}qWt|�S)a
        Set multiple keys with it's values on server.

        :param mappings: A dict with keys/values
        :type mappings: dict
        :param time: Time in seconds that your key will expire.
        :type time: int
        :param compress_level: How much to compress.
            0 = no compression, 1 = fastest, 9 = slowest but best,
            -1 = default compression level.
        :type compress_level: int
        :return: List of keys that failed to be set on any server.
        :rtype: list
        )r)r!r�	set_multi�list)rZmappingsr#rr$rrrr	r%�s
zReplicatingClient.set_multicCs4g}x&|jD]}|j|j||||d��qWt|�S)aP
        Add a key/value to server ony if it does not exist.

        :param key: Key's name
        :type key: six.string_types
        :param value: A value to be stored on server.
        :type value: object
        :param time: Time in seconds that your key will expire.
        :type time: int
        :param compress_level: How much to compress.
            0 = no compression, 1 = fastest, 9 = slowest but best,
            -1 = default compression level.
        :type compress_level: int
        :return: True if key is added False if key already exists
        :rtype: bool
        )r)rr �addr")rrrr#rr$rrrr	r'�szReplicatingClient.addcCs4g}x&|jD]}|j|j||||d��qWt|�S)aS
        Replace a key/value to server ony if it does exist.

        :param key: Key's name
        :type key: six.string_types
        :param value: A value to be stored on server.
        :type value: object
        :param time: Time in seconds that your key will expire.
        :type time: int
        :param compress_level: How much to compress.
            0 = no compression, 1 = fastest, 9 = slowest but best,
            -1 = default compression level.
        :type compress_level: int
        :return: True if key is replace False if key does not exists
        :rtype: bool
        )r)rr �replacer")rrrr#rr$rrrr	r(�szReplicatingClient.replacecCs.g}x |jD]}|j|j||��qWt|�S)z�
        Delete a key/value from server. If key does not exist, it returns True.

        :param key: Key's name to be deleted
        :param cas: CAS of the key
        :return: True in case o success and False in case of failure.
        )rr �deleter")rrrr$rrrr	r)�szReplicatingClient.deletecCs,g}x|jD]}|j|j|��qWt|�S)N)rr �delete_multi�all)rrr$rrrr	r*�szReplicatingClient.delete_multi�@BcCs4g}x&|jD]}|j|j||||d��qW|dS)a�
        Increment a key, if it exists, returns it's actual value, if it don't, return 0.

        :param key: Key's name
        :type key: six.string_types
        :param value: Number to be incremented
        :type value: int
        :param default: If key not set, initialize to this value
        :type default: int
        :param time: Time in seconds that your key will expire.
        :type time: int
        :return: Actual value of the key on server
        :rtype: int
        )rr#r)rr �incr)rrrrr#r$rrrr	r-�szReplicatingClient.incrcCs4g}x&|jD]}|j|j||||d��qW|dS)a
        Decrement a key, if it exists, returns it's actual value, if it don't, return 0.
        Minimum value of decrement return is 0.

        :param key: Key's name
        :type key: six.string_types
        :param value: Number to be decremented
        :type value: int
        :param default: If key not set, initialize to this value
        :type default: int
        :param time: Time in seconds that your key will expire.
        :type time: int
        :return: Actual value of the key on server
        :rtype: int
        )rr#r)rr �decr)rrrrr#r$rrrr	r.szReplicatingClient.decr)NF)F���)rr/r/)rr/r/)rr/r/)rr/r/)rr/)r)rr,)rr,)�__name__�
__module__�__qualname__�__doc__r
r
rrrr!rr%r'r(r)r*r-r.rrrr	rs








rN)Zbmemcached.client.mixinrrrrrr	�<module>s