Caching database data in python
Asked Answered
P

2

8

In the project I need to cache the database data fetched from each request.So that from next time onwards the data(table rows) will be picked from cache instead of db thereby improving performance.In DB i have more than 10M data rows. I was going through the beaker cache documentation,from which it seems that it will only cache the function along with the arguments as keys.So how this can store the table data which is my main objective? Or are there any other good database caching modules available in python?

Planchette answered 2/4, 2012 at 7:24 Comment(0)
B
2

FWIW, here's a simple and fast LRU cache is useful caching the results of DB queries: http://code.activestate.com/recipes/578078

Badlands answered 2/4, 2012 at 7:48 Comment(0)
S
2

Beaker is configurable to cache anything like your database calls too. They are designed for WSGI style application where you interact with the database through your controller methods and beaker sits as a wrapper on those controller methods and thus caches the data returned from the database through those methods.

Depending upon how you are accessing the data from the database, you should be looking for memcached. It has python apis and then is available from different frameworks like Django and also as beaker extension.

Symbiosis answered 2/4, 2012 at 7:46 Comment(0)
B
2

FWIW, here's a simple and fast LRU cache is useful caching the results of DB queries: http://code.activestate.com/recipes/578078

Badlands answered 2/4, 2012 at 7:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.