I have an object which loads all the data from DB Object_X
.
This object has a few methods defined. I pass some parameter and based on parameter I call one of the functions in Object_X
, it uses pre-populated data in object and parameter to get some result.
I have created a web service which invokes any method defined in Object_X
and returns a result.
My problem is that for every request I am loading all the data from db again and again which is time consuming. Is there a way that I can load the data one time when I start a server and uses the same object for each subsequent request?
I suppose you are using web.py frame work. And it will base on how you use web.py. For simplest way, use included CherryPy WSGI server, you can try this:
Every time when you visit
You will see
The number keep increasing every time you visit it. Which means server remember the status, also means inc_num only start once.