# Path: falconswagger/models/orm/redis_base.py
# class ModelRedisBaseMeta(ModelLoggerMetaMixin, ModelOrmHttpMetaMixin):
# 
#     def __init__(cls, name, base_classes, attributes):
#         cls._set_logger()
# 
#         if hasattr(cls, '__schema__'):
#             cls._set_routes()
#         else:
#             cls._set_key()
# 
#     def _to_list(cls, objs):
#         return objs if isinstance(objs, list) else [objs]
# 
#     def get_filters_names_key(cls):
#         return cls.__key__ + '_filters_names'
# 
#     def get_key(cls, filters_names=None):
#         if not filters_names or filters_names == cls.__key__:
#             return cls.__key__
# 
#         return '{}_{}'.format(cls.__key__, filters_names)
# 
#     def get_instance_key(cls, instance, id_names=None):
#         if isinstance(instance, dict):
#             ids_ = [str(v) for v in ModelRedisBaseMeta.get_ids_values(cls, instance, id_names)]
#         else:
#             ids_ = [str(v) for v in cls.get_ids_values(instance, id_names)]
# 
#         return cls.__keys_separator__.decode().join(ids_).encode()
# 
#     def get_ids_values(cls, obj, keys=None):
#         if keys is None:
#             keys = cls.__id_names__
# 
#         return tuple([dict.get(obj, key) for key in sorted(keys)])
# 
# class ModelRedisBase(object):
#     __session__ = None
#     __authorizer__ = None
#     __api__ = None
#     __id_names__ = None
# 
#     def get_key(self, id_names=None):
#         return type(self).get_instance_key(self, id_names)


from falconswagger.models.orm.redis_base import ModelRedisBaseMeta, ModelRedisBase
from collections import OrderedDict
from copy import deepcopy
from types import MethodType
import msgpack
                    continue

                set_map[key] = msgpack.dumps(obj)
                counter += 1

                if counter == cls.CHUNKS:
                    session.redis_bind.hmset(cls.__key__, set_map)
                    set_map = OrderedDict()
                    counter = 0

            if set_map:
                session.redis_bind.hmset(cls.__key__, set_map)

        if keys_objs_to_del:
            session.redis_bind.hdel(cls.__key__, *keys_objs_to_del.keys())

        return list(keys_objs_map.values()) or list(keys_objs_to_del.values())

    def _build_keys_objs_map_with_ids(cls, objs, ids):
        ids = cls._to_list(ids)
        keys_objs_map = OrderedDict()

        for obj in objs:
            obj_ids = cls(obj).get_ids_map(ids[0].keys())
            if obj_ids in ids:
                keys_objs_map[cls._build_key(obj_ids)] = obj

        return keys_objs_map

    def _build_key(cls, id_):

# Path: falconswagger/models/orm/redis_base.py
# class ModelRedisBaseMeta(ModelLoggerMetaMixin, ModelOrmHttpMetaMixin):
# 
#     def __init__(cls, name, base_classes, attributes):
#         cls._set_logger()
# 
#         if hasattr(cls, '__schema__'):
#             cls._set_routes()
#         else:
#             cls._set_key()
# 
#     def _to_list(cls, objs):
#         return objs if isinstance(objs, list) else [objs]
# 
#     def get_filters_names_key(cls):
#         return cls.__key__ + '_filters_names'
# 
#     def get_key(cls, filters_names=None):
#         if not filters_names or filters_names == cls.__key__:
#             return cls.__key__
# 
#         return '{}_{}'.format(cls.__key__, filters_names)
# 
#     def get_instance_key(cls, instance, id_names=None):
#         if isinstance(instance, dict):
#             ids_ = [str(v) for v in ModelRedisBaseMeta.get_ids_values(cls, instance, id_names)]
#         else:
#             ids_ = [str(v) for v in cls.get_ids_values(instance, id_names)]
# 
#         return cls.__keys_separator__.decode().join(ids_).encode()
# 
#     def get_ids_values(cls, obj, keys=None):
#         if keys is None:
#             keys = cls.__id_names__
# 
#         return tuple([dict.get(obj, key) for key in sorted(keys)])
# 
# class ModelRedisBase(object):
#     __session__ = None
#     __authorizer__ = None
#     __api__ = None
#     __id_names__ = None
# 
#     def get_key(self, id_names=None):
#         return type(self).get_instance_key(self, id_names)


# Path: falconswagger/models/orm/redis.py
from falconswagger.models.orm.redis_base import ModelRedisBaseMeta, ModelRedisBase
from collections import OrderedDict
from copy import deepcopy
from types import MethodType
import msgpack

                    continue

                set_map[key] = msgpack.dumps(obj)
                counter += 1

                if counter == cls.CHUNKS:
                    session.redis_bind.hmset(cls.__key__, set_map)
                    set_map = OrderedDict()
                    counter = 0

            if set_map:
                session.redis_bind.hmset(cls.__key__, set_map)

        if keys_objs_to_del:
            session.redis_bind.hdel(cls.__key__, *keys_objs_to_del.keys())

        return list(keys_objs_map.values()) or list(keys_objs_to_del.values())

    def _build_keys_objs_map_with_ids(cls, objs, ids):
        ids = cls._to_list(ids)
        keys_objs_map = OrderedDict()

        for obj in objs:
            obj_ids = cls(obj).get_ids_map(ids[0].keys())
            if obj_ids in ids:
                keys_objs_map[cls._build_key(obj_ids)] = obj

        return keys_objs_map

    def _build_key(cls, id_):

        return cls.get_instance_key(id_, id_.keys())