Cache the result of a MySQLdb database query in memory
- by ensnare
Our application fetches the correct database server from a pool of database servers. So each query is really 2 queries, and they look like this:
Fetch the correct DB server
Execute the query
We do this so we can take DB servers online and offline as necessary, as well as for load-balancing.
But the first query seems like it could be cached to memory, so it only actually queries the database every 5 or 10 minutes or so.
What's the best way to do this?
Thanks.