def json2redis(data, r):
    if isinstance(data, types.ListType):
        for row in data:
            channel = row['channel']
            data_type = row['data_type']
            rkey = 'channel_{}_{}'.format(channel, data_type)
            r.lpush(rkey, row)
    else:
        channel = data['channel']
        data_type = data['data_type']
        rkey = 'channel_{}_{}'.format(channel, data_type)
        r.lpush(rkey, data)
def json2redis(data, r):
    if isinstance(data, types.ListType):
        for row in data:
            channel = row['channel']
            data_type = row['data_type']
            rkey = 'channel_{}_{}'.format(channel, data_type)
            r.lpush(rkey, row)
    else:
        channel = data['channel']
        data_type = data['data_type']
        rkey = 'channel_{}_{}'.format(channel, data_type)
        r.lpush(rkey, data)