# Path: aredis/exceptions.py
# class ResponseError(RedisError):
#     pass
# 
# class RedisError(Exception):
#     pass
# 
# class DataError(RedisError):
#     pass
# 
# Path: aredis/utils.py
# def merge_result(res):
#     """
#     Merges all items in `res` into a list.
# 
#     This command is used when sending a command to multiple nodes
#     and they result from each node should be merged into a single list.
#     """
#     if not isinstance(res, dict):
#         raise ValueError('Value should be of dict type')
# 
#     result = set([])
# 
#     for _, v in res.items():
#         for value in v:
#             result.add(value)
# 
#     return list(result)
# 
# class NodeFlag:
#     BLOCKED = 'blocked'
#     ALL_NODES = 'all-nodes'
#     ALL_MASTERS = 'all-masters'
#     RANDOM = 'random'
#     SLOT_ID = 'slot-id'
# 
# def first_key(res):
#     """
#     Returns the first result for the given command.
# 
#     If more then 1 result is returned then a `RedisClusterException` is raised.
#     """
#     if not isinstance(res, dict):
#         raise ValueError('Value should be of dict type')
# 
#     if len(res.keys()) != 1:
#         raise RedisClusterException("More then 1 result from command")
# 
#     return list(res.values())[0]
# 
# def b(x):
#     return x.encode('latin-1') if not isinstance(x, bytes) else x
# 
# def dict_merge(*dicts):
#     merged = {}
#     for d in dicts:
#         merged.update(d)
#     return merged
# 
# def int_or_none(response):
#     if response is None:
#         return None
#     return int(response)
# 
# def bool_ok(response):
#     return nativestr(response) == 'OK'
# 
# def string_keys_to_dict(key_string, callback):
#     return dict.fromkeys(key_string.split(), callback)
# 
# def list_keys_to_dict(key_list, callback):
#     return dict.fromkeys(key_list, callback)


import datetime
import time as mod_time
from aredis.exceptions import (ResponseError,
                               RedisError,
                               DataError)
from aredis.utils import (merge_result,
                          NodeFlag,
                          first_key,
                          b, dict_merge,
                          int_or_none,
                          bool_ok,
                          string_keys_to_dict,
                          list_keys_to_dict)
        'MOVE': NodeFlag.BLOCKED,
        'RANDOMKEY': NodeFlag.RANDOM,
        'SCAN': NodeFlag.ALL_MASTERS,
        },
        list_keys_to_dict(
            ['KEYS'],
            NodeFlag.ALL_NODES
        )
    )

    RESULT_CALLBACKS = {
        'KEYS': merge_result,
        'RANDOMKEY': first_key,
        'SCAN': lambda res: res
    }

    async def rename(self, src, dst):
        """
        Rename key ``src`` to ``dst``

        Cluster impl:
            This operation is no longer atomic because each key must be querried
            then set in separate calls because they maybe will change cluster node
        """
        if src == dst:
            raise ResponseError("source and destination objects are the same")

        data = await self.dump(src)

        if data is None:

# Path: aredis/exceptions.py
# class ResponseError(RedisError):
#     pass
# 
# class RedisError(Exception):
#     pass
# 
# class DataError(RedisError):
#     pass
# 
# Path: aredis/utils.py
# def merge_result(res):
#     """
#     Merges all items in `res` into a list.
# 
#     This command is used when sending a command to multiple nodes
#     and they result from each node should be merged into a single list.
#     """
#     if not isinstance(res, dict):
#         raise ValueError('Value should be of dict type')
# 
#     result = set([])
# 
#     for _, v in res.items():
#         for value in v:
#             result.add(value)
# 
#     return list(result)
# 
# class NodeFlag:
#     BLOCKED = 'blocked'
#     ALL_NODES = 'all-nodes'
#     ALL_MASTERS = 'all-masters'
#     RANDOM = 'random'
#     SLOT_ID = 'slot-id'
# 
# def first_key(res):
#     """
#     Returns the first result for the given command.
# 
#     If more then 1 result is returned then a `RedisClusterException` is raised.
#     """
#     if not isinstance(res, dict):
#         raise ValueError('Value should be of dict type')
# 
#     if len(res.keys()) != 1:
#         raise RedisClusterException("More then 1 result from command")
# 
#     return list(res.values())[0]
# 
# def b(x):
#     return x.encode('latin-1') if not isinstance(x, bytes) else x
# 
# def dict_merge(*dicts):
#     merged = {}
#     for d in dicts:
#         merged.update(d)
#     return merged
# 
# def int_or_none(response):
#     if response is None:
#         return None
#     return int(response)
# 
# def bool_ok(response):
#     return nativestr(response) == 'OK'
# 
# def string_keys_to_dict(key_string, callback):
#     return dict.fromkeys(key_string.split(), callback)
# 
# def list_keys_to_dict(key_list, callback):
#     return dict.fromkeys(key_list, callback)


# Path: aredis/commands/keys.py
import datetime
import time as mod_time
from aredis.exceptions import (ResponseError,
                               RedisError,
                               DataError)
from aredis.utils import (merge_result,
                          NodeFlag,
                          first_key,
                          b, dict_merge,
                          int_or_none,
                          bool_ok,
                          string_keys_to_dict,
                          list_keys_to_dict)

        'MOVE': NodeFlag.BLOCKED,
        'RANDOMKEY': NodeFlag.RANDOM,
        'SCAN': NodeFlag.ALL_MASTERS,
        },
        list_keys_to_dict(
            ['KEYS'],
            NodeFlag.ALL_NODES
        )
    )

    RESULT_CALLBACKS = {
        'KEYS': merge_result,
        'RANDOMKEY': first_key,
        'SCAN': lambda res: res
    }

    async def rename(self, src, dst):
        """
        Rename key ``src`` to ``dst``

        Cluster impl:
            This operation is no longer atomic because each key must be querried
            then set in separate calls because they maybe will change cluster node
        """
        if src == dst:
            raise ResponseError("source and destination objects are the same")

        data = await self.dump(src)

        if data is None:

            raise ResponseError("no such key")