Caching MongoDB connections in Django
问题 I'm using the standard (as opposed to NonRel) version of Django connected to PostgreSQL on top of Apache + mod_wsgi. This setup also connects to MongoDB (some data is saved externally). Right now I have to create a new MongoDB connection for each Django request, and pass it along throughout the call stack to all functions that require access to MongoDB. Is there a way to cache connections between requests? Edit At the risk of blasphemy, would a global variable work in this case? 回答1: There