问题
I have one row in my oracle cache table. I'm trying to clear it using standard django way:
from django.core.cache import cache
cache.clear()
But it doesn't work! The row is still in my cache table.
So I run python manage.py sell
and put some code from DatabaseCache.clear()
method:
from django.db import connections
table = connections['cache'].ops.quote_name('ws_cache_table')
cursor = connections['cache'].cursor()
cursor.execute('DELETE FROM %s' % table)
But it doesn't work either...
I don't get any exceptions thrown, my 'cache' connection is configured correctly in settings.py
.
When I open SQL Developer and put
DELETE FROM ws_cache_table
Table gets truncated correctly.
On the other hand, when I add:
connections['cache'].commit()
I get exception django.db.transaction.TransactionManagementError: This code isn't under transaction management
thrown but the table is truncated now.
The question is: what should I do to get my table truncated but without throwing exception?
Is this a bug in django DatabaseCache.clear()
method?
I'm using django 1.4.
来源:https://stackoverflow.com/questions/19024127/django-cant-clear-database-cache-on-oracle-backend