# Path: library/config/database.py

# 
# Path: library/utils/type_conv.py
# def bytes2string(data, encoding='utf-8'):
#     
#     '''
#     简单粗暴地把bytes字符串转换为str字符串
#     data必须是简单bytes格式
#     如果复杂，转化可能成功，但后续处理出差几率很大，请使用obj2string方法
#     :parm
#         data：字符串
#         encoding：编码
#     '''
#         
#     if isinstance(data, str):
#         return data
#     
#     try :
#         data = data.decode(encoding)
#         # result.decode('ascii') bytes解码会得到str
#     except :
#         new_data = obj2string(data, encoding=encoding)
#         if new_data[0] :
#             data = new_data[1]
#         
#     return data


import pickle, redis, logging
from library.config.database import redis_config
from library.utils.type_conv import bytes2string
            db_name = 0
        
        pwd = dest_conf['pwd']
        try :
            pwd = dest_conf['pwd']
        except :
            pwd = None
        
        try :
            max_connections = dest_conf['max_connections']
        except :
            max_connections = 10
        # optype = redis_config['default']['type']
        socket_timeout = config['socket_timeout']
        socket_connect_timeout = config['socket_connect_timeout']
        socket_keepalive = config['socket_keepalive']
        
        self.log_prefix = 'Redis服务器' + host + ':' + str(port) + '/' + str(db_name)

        pool = redis.ConnectionPool(host=host, port=port, db=db_name, max_connections=max_connections, password=pwd, socket_timeout=socket_timeout, socket_connect_timeout=socket_connect_timeout, socket_keepalive=socket_keepalive)
        self.connecter = redis.Redis(connection_pool=pool)
     
     
    def _single_get(self, name):
        '''
        通过_single_get()获取指定name列表或者单个name的value
        '''
        try :
            result = self.connecter.get(name)
            if result != None :

# Path: library/config/database.py

# 
# Path: library/utils/type_conv.py
# def bytes2string(data, encoding='utf-8'):
#     
#     '''
#     简单粗暴地把bytes字符串转换为str字符串
#     data必须是简单bytes格式
#     如果复杂，转化可能成功，但后续处理出差几率很大，请使用obj2string方法
#     :parm
#         data：字符串
#         encoding：编码
#     '''
#         
#     if isinstance(data, str):
#         return data
#     
#     try :
#         data = data.decode(encoding)
#         # result.decode('ascii') bytes解码会得到str
#     except :
#         new_data = obj2string(data, encoding=encoding)
#         if new_data[0] :
#             data = new_data[1]
#         
#     return data


# Path: library/storage/database/redis_api.py
import pickle, redis, logging
from library.config.database import redis_config
from library.utils.type_conv import bytes2string

            db_name = 0
        
        pwd = dest_conf['pwd']
        try :
            pwd = dest_conf['pwd']
        except :
            pwd = None
        
        try :
            max_connections = dest_conf['max_connections']
        except :
            max_connections = 10
        # optype = redis_config['default']['type']
        socket_timeout = config['socket_timeout']
        socket_connect_timeout = config['socket_connect_timeout']
        socket_keepalive = config['socket_keepalive']
        
        self.log_prefix = 'Redis服务器' + host + ':' + str(port) + '/' + str(db_name)

        pool = redis.ConnectionPool(host=host, port=port, db=db_name, max_connections=max_connections, password=pwd, socket_timeout=socket_timeout, socket_connect_timeout=socket_connect_timeout, socket_keepalive=socket_keepalive)
        self.connecter = redis.Redis(connection_pool=pool)
     
     
    def _single_get(self, name):
        '''
        通过_single_get()获取指定name列表或者单个name的value
        '''
        try :
            result = self.connecter.get(name)
            if result != None :

                result = bytes2string(result)