Optimization of Google App Engine Code
Google App Engine is yelling at me about the high amount of quota that this code is using.
What can I do to make it less heavy?
public void doGet(HttpServletRequest req, HttpServletResponse resp)开发者_如何学Go
throws IOException, ServletException {
PersistenceManager pm = PMF.get().getPersistenceManager();
HttpSession session = req.getSession();
if(session.isNew()){
session.invalidate();
resp.sendRedirect("/login.html");
}
else {
User usr22 = (User) session.getAttribute("username");
String query = "select from veep.User where email == '"+ usr22.getEmail() +"'";
List<User> users = (List<User>) pm.newQuery(query).execute();
User usr = users.get(0);
System.out.println("estou no SERVMVCCCCC!!" + usr);
List<String> discsNAct = usr.getDisciplinasNAct();
List<String> discsActs = usr.getDisciplinasAct();
req.setAttribute("nact", discsNAct);
req.setAttribute("act", discsActs);
req.setAttribute("discs", discsNAct);
session.invalidate();
session = req.getSession();
session.setAttribute("username", usr);
session.setAttribute("loggedIn", new String("true"));
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/conta_d.jsp");
dispatcher.forward(req, resp);
try {
pm.makePersistent(usr);
} finally {
pm.close();
}
}
}
精彩评论