Can I load lots of data only once and use it on each request?
- by eikes
Is there a way to load a big data object into the memory, which usually has to be loaded at each request, only once?
In Java you can instantiate an object in a servlet when this servlet is loaded, but once it's there you can use it in any request. Example is below. Can this be done in PHP?
public class SampleServlet extends HttpServlet {
private static HugeGraphObject hgo;
public void init() {
hgo = HugeGraphObjectFactory.get();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String param = request.getParameter("q");
response.getWriter().write(hgo.getSomeThing(param));
}
}