Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Database Caching

I'm working on a small project, and I wanted to provide multiple caching options to the end user. I figured with Django it's pretty simplistic to swap memcached for database or file based caching. My memcached implementation works like a champ without any issues. I placed time stamps on my pages, and curl consistently shows the older timestamps in locations where I want caching to work properly. However, when I switch over to the database caching, I don't get any entries in the database, and caching blatantly doesn't work.

From what I see in the documentation all that should be necessary is to change the backend from:

CACHE_BACKEND = 'memcached://localhost:11211'

To:

CACHE_BACKEND = 'db://cache_table'

The table exists after running the required manage.py (createcachetable) line, and I can view it just fine. I'm currently in testing, so I am using sqlite3, but that shouldn't matter as far as I can tell. I can confirm that the table is completely empty, and hasn't been written to at any point. Also, as I stated previously, my timestamps are 'wrong' as well, giving me more evidence that something isn't quite right.

Any thoughts? I'm using sqlite3, Django 1.0.2, python 2.6, serving via Apache currently on an Ubuntu Jaunty machine. I'm sure I'm just glossing over something simple. Thanks for any help provided.

like image 339
f4nt Avatar asked Mar 01 '23 13:03

f4nt


1 Answers

According to the documentation you're supposed to create the table not by using syncdb but with the following:

python manage.py createcachetable cache_table

If you haven't done that, try and see if it doesn't work.

like image 50
lemonad Avatar answered Mar 12 '23 22:03

lemonad