Ticket #15580: 15580.patch
File 15580.patch, 2.5 KB (added by , 14 years ago) |
---|
-
django/core/cache/backends/db.py
126 126 if self._cull_frequency == 0: 127 127 self.clear() 128 128 else: 129 table = connections[db].ops.quote_name(self._table) 129 ops = connections[db].ops 130 table = ops.quote_name(self._table) 130 131 cursor.execute("DELETE FROM %s WHERE expires < %%s" % table, 131 132 [connections[db].ops.value_to_db_datetime(now)]) 132 133 cursor.execute("SELECT COUNT(*) FROM %s" % table) 133 134 num = cursor.fetchone()[0] 134 135 if num > self._max_entries: 135 cursor.execute( "SELECT cache_key FROM %s ORDER BY cache_key LIMIT 1 OFFSET %%s"% table, [num / self._cull_frequency])136 cursor.execute(ops.cache_key_culling_threshold() % table, [num / self._cull_frequency]) 136 137 cursor.execute("DELETE FROM %s WHERE cache_key < %%s" % table, [cursor.fetchone()[0]]) 137 138 138 139 def clear(self): -
django/db/backends/__init__.py
401 401 """ 402 402 return None 403 403 404 def cache_key_culling_threshold(self): 405 """ 406 Returns a SQL query that retrieves the first cache key greater than the 407 n smallest. 408 409 This is used by the 'db' cache backend to determine where to start 410 culling. 411 """ 412 return "SELECT cache_key FROM %s ORDER BY cache_key LIMIT 1 OFFSET %%s" 413 404 414 def date_extract_sql(self, lookup_type, field_name): 405 415 """ 406 416 Given a lookup_type of 'year', 'month' or 'day', returns the SQL that -
django/db/backends/oracle/base.py
111 111 /""" % locals() 112 112 return sequence_sql, trigger_sql 113 113 114 def cache_key_culling_threshold(self): 115 return """SELECT cache_key 116 FROM (SELECT cache_key, rank() OVER (ORDER BY cache_key) AS rank FROM %s) 117 WHERE rank = %%s + 1""" 118 114 119 def date_extract_sql(self, lookup_type, field_name): 115 120 # http://download-east.oracle.com/docs/cd/B10501_01/server.920/a96540/functions42a.htm#1017163 116 121 if lookup_type == 'week_day':