Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib/python3.5/site-packages/aioredis/commands/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/aioredis/commands/__pycache__/hash.cpython-35.pyc



�(Zg�@s[ddlmZddlmZmZmZmZmZGdd�d�Zdd�Z	dS)�)�chain)�wait_ok�wait_convert�wait_make_dict�_NOTSET�	_ScanIterc@seZdZdZdd�Zdd�Zdedd�Zded	d
�Zddd
�Z	ddd�Z
dedd�Zdd�Zdedd�Z
dd�Zdd�Zdd�Zdd�Zdedd �Zd!d"d"d#d$�Zd%d"d&d"d'd(�Zd)d*�Zd"S)+�HashCommandsMixinzVHash commands mixin.

    For commands details see: http://redis.io/commands#hash
    cGs|jd|||�S)zDelete one or more hash fields.sHDEL)�execute)�self�key�field�fields�r�G/opt/alt/python35/lib/python3.5/site-packages/aioredis/commands/hash.py�hdelszHashCommandsMixin.hdelcCs"|jd||�}t|t�S)zDetermine if hash field exists.sHEXISTS)r	r�bool)r
rr�futrrr�hexistsszHashCommandsMixin.hexists�encodingcCs|jd||d|�S)zGet the value of a hash field.sHGETr)r	)r
rrrrrr�hgetszHashCommandsMixin.hgetcCs"|jd|d|�}t|�S)z(Get all the fields and values in a hash.sHGETALLr)r	r)r
rrrrrr�hgetallszHashCommandsMixin.hgetall�cCs|jd|||�S)z@Increment the integer value of a hash field by the given number.sHINCRBY)r	)r
rr�	incrementrrr�hincrby$szHashCommandsMixin.hincrbyg�?cCs%|jd|||�}t|t�S)z>Increment the float value of a hash field by the given number.sHINCRBYFLOAT)r	r�float)r
rrrrrrr�hincrbyfloat(szHashCommandsMixin.hincrbyfloatcCs|jd|d|�S)zGet all the fields in a hash.sHKEYSr)r	)r
rrrrr�hkeys-szHashCommandsMixin.hkeyscCs|jd|�S)z#Get the number of fields in a hash.sHLEN)r	)r
rrrr�hlen1szHashCommandsMixin.hlencGs|jd|||d|�S)z'Get the values of all the given fields.sHMGETr)r	)r
rrrr
rrr�hmget5szHashCommandsMixin.hmgetcGsAt|�ddkr"td��t|jd||||��S)z,Set multiple hash fields to multiple values.�rz#length of pairs must be even numbersHMSET)�len�	TypeErrorrr	)r
rr�value�pairsrrr�hmset9szHashCommandsMixin.hmsetcOs�|r|rtd��f}t|�dkrAtd��nkt|�dkr�t|dt�sutd��n|dr�|r�td��tj|dj��}tj|j��}t|j	d|t||���S)a0Set multiple hash fields to multiple values.

        dict can be passed as first positional argument:

        >>> await redis.hmset_dict(
        ...     'key', {'field1': 'value1', 'field2': 'value2'})

        or keyword arguments can be used:

        >>> await redis.hmset_dict(
        ...     'key', field1='value1', field2='value2')

        or dict argument can be mixed with kwargs:

        >>> await redis.hmset_dict(
        ...     'key', {'field1': 'value1'}, field2='value2')

        .. note:: ``dict`` and ``kwargs`` not get mixed into single dictionary,
           if both specified and both have same key(s) -- ``kwargs`` will win:

           >>> await redis.hmset_dict('key', {'foo': 'bar'}, foo='baz')
           >>> await redis.hget('key', 'foo', encoding='utf-8')
           'baz'

        z args or kwargs must be specifiedrz"single positional argument allowedrzargs[0] must be dictzargs[0] is empty dictsHMSET)
r!r �
isinstance�dict�
ValueErrorr�
from_iterable�itemsrr	)r
r�args�kwargsr#Zkwargs_pairsrrr�
hmset_dict?s	zHashCommandsMixin.hmset_dictcCs|jd|||�S)z%Set the string value of a hash field.sHSET)r	)r
rrr"rrr�hsethszHashCommandsMixin.hsetcCs|jd|||�S)z@Set the value of a hash field, only if the field does not exist.sHSETNX)r	)r
rrr"rrr�hsetnxlszHashCommandsMixin.hsetnxcCs|jd|d|�S)zGet all the values in a hash.sHVALSr)r	)r
rrrrr�hvalspszHashCommandsMixin.hvalsrNcCsi||g}|dk	o*|jd|g�|dk	oI|jd|g�|jd|�}t|t�S)z8Incrementally iterate hash fields and associated values.NsMATCHsCOUNTsHSCAN)�extendr	r�_make_pairs)r
rZcursor�match�countr*rrrr�hscants
zHashCommandsMixin.hscanr2r3cst����fdd��S)z�Incrementally iterate sorted set items using async for.

        Usage example:

        >>> async for name, val in redis.ihscan(key, match='something*'):
        ...     print('Matched:', name, '->', val)

        cs�j�|d�d��S)Nr2r3)r4)�cur)r3rr2r
rr�<lambda>�sz*HashCommandsMixin.ihscan.<locals>.<lambda>)r)r
rr2r3r)r3rr2r
r�ihscan|s	zHashCommandsMixin.ihscancCs|jd||�S)z,Get the length of the value of a hash field.sHSTRLEN)r	)r
rrrrr�hstrlen�szHashCommandsMixin.hstrlen)�__name__�
__module__�__qualname__�__doc__rrrrrrrrrrr$r,r-r.r/r4r7r8rrrrrs$)
rcCs3t|d�}t|d�tt||��fS)Nrr)�iter�int�list�zip)�obj�itrrrr1�sr1N)
�	itertoolsrZ
aioredis.utilrrrrrrr1rrrr�<module>s(	�