Django can't clear database cache on Oracle backend

可紊 提交于 2019-12-11 18:01:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!