I am loading a pickled dictionary into memory. I need it to be
available to all users all the time. It needs to be loaded only once
at application startup.
I wrote the following code and put it in models directory
code: load_table.py
import cPickle as pickle
"""
Load the file into memory and message the number of entries
"""
f = open('tables.pkl','rb')
session.tables = pickle.load(f)
f.close()
terms = len(tables.keys())
This made the 'table' variable available globally to all functions in
the controller. I was initially using a very small table. Now that the
table size has increased, it is taking a long time to query it. Almost
equal to loading it each time. How can I speed this up.
Should I load it in index() and access via session.table (global)