Cache the result of a MySQLdb database query in memory

Posted by ensnare on Stack Overflow See other posts from Stack Overflow or by ensnare
Published on 2010-04-05T04:04:40Z Indexed on 2010/04/05 4:13 UTC
Read the original article Hit count: 606

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:

  1. Fetch the correct DB server
  2. 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.

© Stack Overflow or respective owner

Related posts about python

Related posts about mysqldb