Author: mtredinnick
Date: 2007-10-21 14:19:32 -0500 (Sun, 21 Oct 2007)
New Revision: 6589
Modified:
django/trunk/django/core/cache/backends/db.py
Log:
Fixed a bug in the db cache backend introduced in [6572].
Modified: django/trunk/django/core/cache/backends/db.py
===================================================================
--- django/trunk/django/core/cache/backends/db.py 2007-10-21 19:10:10 UTC
(rev 6588)
+++ django/trunk/django/core/cache/backends/db.py 2007-10-21 19:19:32 UTC
(rev 6589)
@@ -24,9 +24,6 @@
except (ValueError, TypeError):
self._cull_frequency = 3
- def add(self, key, value, timeout=None):
- return self._base_set('add', key, value, timeout)
-
def get(self, key, default=None):
cursor = connection.cursor()
cursor.execute("SELECT cache_key, value, expires FROM %s WHERE
cache_key = %%s" % self._table, [key])
@@ -43,6 +40,9 @@
def set(self, key, value, timeout=None):
return self._base_set('set', key, value, timeout)
+ def add(self, key, value, timeout=None):
+ return self._base_set('add', key, value, timeout)
+
def _base_set(self, mode, key, value, timeout=None):
if timeout is None:
timeout = self.default_timeout
@@ -59,8 +59,7 @@
if mode == 'set' and cursor.fetchone():
cursor.execute("UPDATE %s SET value = %%s, expires = %%s WHERE
cache_key = %%s" % self._table, [encoded, str(exp), key])
else:
- if mode == 'add':
- cursor.execute("INSERT INTO %s (cache_key, value, expires)
VALUES (%%s, %%s, %%s)" % self._table, [key, encoded, str(exp)])
+ cursor.execute("INSERT INTO %s (cache_key, value, expires)
VALUES (%%s, %%s, %%s)" % self._table, [key, encoded, str(exp)])
except DatabaseError:
# To be threadsafe, updates/inserts are allowed to fail silently
pass
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---