Added function to purge stale cache documents

This commit is contained in:
2011-09-06 17:37:18 +01:00
parent e01fd630ba
commit 267b9153a3

View File

@@ -75,3 +75,12 @@ class DbCacheHandler:
self.disconnect()
except sqlite3.Error as e:
self.log.error("Error storing document: %s", e.args[0])
def purge_stale(self):
self.log.info("Purging stale cached documents")
try:
self.cursor.execute("DELETE FROM api_cache WHERE datetime(cacheduntil, 'unixepoch') >= current_timestamp")
self.conn.commit()
self.disconnect()
except sqlite3.Error as e:
self.log.error("Error purging document cache: %s", e.args[0])