Ticket #17268: t17268.diff

File t17268.diff, 1.2 KB (added by Florian Apolloner, 12 years ago)
  • django/core/cache/backends/db.py

    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):  
    107107                       "WHERE cache_key = %%s" % table, [key])
    108108        try:
    109109            result = cursor.fetchone()
     110            sid = transaction.savepoint()
    110111            if result and (mode == 'set' or
    111112                    (mode == 'add' and result[1] < now)):
    112113                cursor.execute("UPDATE %s SET value = %%s, expires = %%s "
    class DatabaseCache(BaseDatabaseCache):  
    116117                cursor.execute("INSERT INTO %s (cache_key, value, expires) "
    117118                               "VALUES (%%s, %%s, %%s)" % table,
    118119                               [key, encoded, connections[db].ops.value_to_db_datetime(exp)])
     120            transaction.savepoint_commit(sid)
    119121        except DatabaseError:
    120122            # To be threadsafe, updates/inserts are allowed to fail silently
     123            transaction.savepoint_rollback(sid)
    121124            transaction.rollback_unless_managed(using=db)
    122125            return False
    123126        else:
Back to Top