I am trying to cache some API responses in my website (written with web.py).
Thus I want to save a variable somewhere on the server side between different calls to my webserver.
Were is the best place to store this variables?
I have acctually not been able to find -any- place where I can store them as of yet.
Since my index object seems to be re-initialized with every call to the webapp I can not store the varable as an attribute.
Neither do I seem able to reach the variable if I declare them in the script that initialize the webapp.
cacheInfo = "something"
class Index:
def GET(self):
render.index(cacheInfo)
if __name__ == "__main__":
app.run()
Try using the pickle module. It stores and retrieves variables from files. CGI scripts don’t persist between runs, so you need to store the data in a file or database.