mirror of
https://github.com/nikdoof/apishiv.git
synced 2025-12-11 14:42:18 +00:00
Added function to purge stale cache documents
This commit is contained in:
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user