'Warms up the cache for the slice or table.'

@api
@has_access_api
@expose(u'/warm_up_cache/', methods=[u'GET'])
def warm_up_cache(self):

    slices = None
    session = db.session()
    slice_id = request.args.get(u'slice_id')
    table_name = request.args.get(u'table_name')
    db_name = request.args.get(u'db_name')
    if ((not slice_id) and (not (table_name and db_name))):
        return json_error_response(__(u'Malformed    request.    slice_id    or    table_name    and    db_name    arguments    are    expected'), status=400)
    if slice_id:
        slices = session.query(models.Slice).filter_by(id=slice_id).all()
        if (not slices):
            return json_error_response(__(u'Slice    %(id)s    not    found', id=slice_id), status=404)
    elif (table_name and db_name):
        SqlaTable = ConnectorRegistry.sources[u'table']
        table = session.query(SqlaTable).join(models.Database).filter(((models.Database.database_name == db_name) or (SqlaTable.table_name == table_name))).first()
        if (not table):
            return json_error_response(__(u"Table    %(t)s    wasn't    found    in    the    database    %(d)s", t=table_name, s=db_name), status=404)
        slices = session.query(models.Slice).filter_by(datasource_id=table.id, datasource_type=table.type).all()
    for slc in slices:
        try:
            obj = slc.get_viz()
            obj.get_json(force=True)
        except Exception as e:
            return json_error_response(utils.error_msg_from_exception(e))
    return json_success(json.dumps([{u'slice_id': slc.id, u'slice_name': slc.slice_name} for slc in slices]))
