My Django site recently started throwing errors from my caching code and I can't figure out why...
I call:
from django.core.cache import cache
cache.set('blogentry', some_value)
And the error thrown by Django is:
TransactionManagementError: This code isn't under transaction management
But looking at the PostgreSQL database logs, it seems to stem from this error:
STATEMENT: INSERT INTO cache_table (cache_key, value, expires) VALUES (E'blogentry', E'pickled_version_of_some_value', E'2009-07-27 11:10:26')
ERROR: duplicate key value violates unique constraint "cache_table_pkey"
For the life of me I can't figure out why Django is trying to do an INSERT instead of an UPDATE. Any thoughts?