diff --git a/django/core/cache/backends/db.py b/django/core/cache/backends/db.py
index 2baa128..eedbe97 100644
|
a
|
b
|
class DatabaseCache(BaseDatabaseCache):
|
| 107 | 107 | "WHERE cache_key = %%s" % table, [key]) |
| 108 | 108 | try: |
| 109 | 109 | result = cursor.fetchone() |
| | 110 | sid = transaction.savepoint() |
| 110 | 111 | if result and (mode == 'set' or |
| 111 | 112 | (mode == 'add' and result[1] < now)): |
| 112 | 113 | cursor.execute("UPDATE %s SET value = %%s, expires = %%s " |
| … |
… |
class DatabaseCache(BaseDatabaseCache):
|
| 116 | 117 | cursor.execute("INSERT INTO %s (cache_key, value, expires) " |
| 117 | 118 | "VALUES (%%s, %%s, %%s)" % table, |
| 118 | 119 | [key, encoded, connections[db].ops.value_to_db_datetime(exp)]) |
| | 120 | transaction.savepoint_commit(sid) |
| 119 | 121 | except DatabaseError: |
| 120 | 122 | # To be threadsafe, updates/inserts are allowed to fail silently |
| | 123 | transaction.savepoint_rollback(sid) |
| 121 | 124 | transaction.rollback_unless_managed(using=db) |
| 122 | 125 | return False |
| 123 | 126 | else: |