          exp = datetime.fromtimestamp(time.time() + timeout).replace(microsecond=0)
          if num > self._max_entries:
              self._cull(cursor, now)
          encoded = base64.encodestring(pickle.dumps(value, 2)).strip()
          cursor.execute("SELECT key FROM %s WHERE key = %%s" % self._table, [key])
          if cursor.fetchone():
              cursor.execute("UPDATE %s SET value = %%s, expires = %%s WHERE key = %%s" % self._table, [encoded, str(exp), key])
          else:
              cursor.execute("INSERT INTO %s (key, value, expires) VALUES (%%s, %%s, %%s)" % self._table, [key, encoded, str(exp)])
          db.commit()
 
</s> remove             cursor.execute("UPDATE %s SET value = %%s, expires = %%s WHERE key = %%s" % self._table, [encoded, str(exp), key])
 </s> add             cursor.execute("UPDATE %s SET value = %%s, expires = %%s WHERE cache_key = %%s" % self._table, [encoded, str(exp), key]) </s> remove             cursor.execute("INSERT INTO %s (key, value, expires) VALUES (%%s, %%s, %%s)" % self._table, [key, encoded, str(exp)])
 </s> add             cursor.execute("INSERT INTO %s (cache_key, value, expires) VALUES (%%s, %%s, %%s)" % self._table, [key, encoded, str(exp)]) </s> remove                 cursor.execute("SELECT key FROM %s ORDER BY key LIMIT 1 OFFSET %%s" % self._table, [num / self._cull_frequency])
                cursor.execute("DELETE FROM %s WHERE key < %%s" % self._table, [cursor.fetchone()[0]])
 </s> add                 cursor.execute("SELECT cache_key FROM %s ORDER BY cache_key LIMIT 1 OFFSET %%s" % self._table, [num / self._cull_frequency])
                cursor.execute("DELETE FROM %s WHERE cache_key < %%s" % self._table, [cursor.fetchone()[0]]) </s> remove         cursor.execute("DELETE FROM %s WHERE key = %%s" % self._table, [key])
 </s> add         cursor.execute("DELETE FROM %s WHERE cache_key = %%s" % self._table, [key]) </s> remove         cursor.execute("SELECT key, value, expires FROM %s WHERE key = %%s" % self._table, [key])
 </s> add         cursor.execute("SELECT cache_key, value, expires FROM %s WHERE cache_key = %%s" % self._table, [key])
        cursor.execute("SELECT cache_key FROM %s WHERE cache_key = %%s" % self._table, [key])
          exp = datetime.fromtimestamp(time.time() + timeout).replace(microsecond=0)
          if num > self._max_entries:
              self._cull(cursor, now)
          encoded = base64.encodestring(pickle.dumps(value, 2)).strip()
        cursor.execute("SELECT cache_key FROM %s WHERE cache_key = %%s" % self._table, [key])
          if cursor.fetchone():
              cursor.execute("UPDATE %s SET value = %%s, expires = %%s WHERE key = %%s" % self._table, [encoded, str(exp), key])
          else:
              cursor.execute("INSERT INTO %s (key, value, expires) VALUES (%%s, %%s, %%s)" % self._table, [key, encoded, str(exp)])
          db.commit()
keep keep keep keep replace keep keep keep keep keep
 Fixed #515 (again) - renamed "key" field in SQL cache to "cache_key" because 
MySQL reserves "key".


git-svn-id: http://code.djangoproject.com/svn/django/trunk@695 bcc190cf-cafb-0310-a4f2-bffc1f526a37 
django/core/cache.py