potential bypass cloudflare
Build and Push Docker Images / build-and-push (push) Successful in 2m24s
Build and Push Docker Images / build-and-push (push) Successful in 2m24s
This commit is contained in:
@@ -236,10 +236,17 @@ class DatabaseManager:
|
||||
else:
|
||||
cache_expiry = int(time.time()) - (CACHE_EXPIRY_HOURS * 60 * 60) # Convert hours to seconds
|
||||
|
||||
cursor.execute(
|
||||
"SELECT data FROM cache WHERE url = %s AND route = %s AND timestamp > %s",
|
||||
(url, route, cache_expiry)
|
||||
)
|
||||
if self.db_type == "postgresql":
|
||||
cursor.execute(
|
||||
"SELECT data FROM cache WHERE url = %s AND route = %s AND timestamp > %s",
|
||||
(url, route, cache_expiry)
|
||||
)
|
||||
else:
|
||||
cursor.execute(
|
||||
"SELECT data FROM cache WHERE url = ? AND route = ? AND timestamp > ?",
|
||||
(url, route, cache_expiry)
|
||||
)
|
||||
|
||||
result = cursor.fetchone()
|
||||
conn.close()
|
||||
|
||||
@@ -283,19 +290,34 @@ class DatabaseManager:
|
||||
expiry_timestamp = int(time.time()) - (CACHE_EXPIRY_HOURS * 60 * 60)
|
||||
pagination_expiry_timestamp = int(time.time()) - (CACHE_EXPIRY_HOURS * 31 * 60 * 60)
|
||||
|
||||
# Get count of entries to be deleted (non-pagination)
|
||||
cursor.execute("SELECT COUNT(*) FROM cache WHERE route != %s AND timestamp < %s", ('pagination', expiry_timestamp))
|
||||
count_non_pagination = cursor.fetchone()[0]
|
||||
if self.db_type == "postgresql":
|
||||
# Get count of entries to be deleted (non-pagination)
|
||||
cursor.execute("SELECT COUNT(*) FROM cache WHERE route != %s AND timestamp < %s", ('pagination', expiry_timestamp))
|
||||
count_non_pagination = cursor.fetchone()[0]
|
||||
|
||||
# Get count of pagination entries to be deleted
|
||||
cursor.execute("SELECT COUNT(*) FROM cache WHERE route = %s AND timestamp < %s", ('pagination', pagination_expiry_timestamp))
|
||||
count_pagination = cursor.fetchone()[0]
|
||||
# Get count of pagination entries to be deleted
|
||||
cursor.execute("SELECT COUNT(*) FROM cache WHERE route = %s AND timestamp < %s", ('pagination', pagination_expiry_timestamp))
|
||||
count_pagination = cursor.fetchone()[0]
|
||||
|
||||
# Delete old non-pagination entries
|
||||
cursor.execute("DELETE FROM cache WHERE route != %s AND timestamp < %s", ('pagination', expiry_timestamp))
|
||||
# Delete old non-pagination entries
|
||||
cursor.execute("DELETE FROM cache WHERE route != %s AND timestamp < %s", ('pagination', expiry_timestamp))
|
||||
|
||||
# Delete old pagination entries
|
||||
cursor.execute("DELETE FROM cache WHERE route = %s AND timestamp < %s", ('pagination', pagination_expiry_timestamp))
|
||||
# Delete old pagination entries
|
||||
cursor.execute("DELETE FROM cache WHERE route = %s AND timestamp < %s", ('pagination', pagination_expiry_timestamp))
|
||||
else:
|
||||
# Get count of entries to be deleted (non-pagination)
|
||||
cursor.execute("SELECT COUNT(*) FROM cache WHERE route != ? AND timestamp < ?", ('pagination', expiry_timestamp))
|
||||
count_non_pagination = cursor.fetchone()[0]
|
||||
|
||||
# Get count of pagination entries to be deleted
|
||||
cursor.execute("SELECT COUNT(*) FROM cache WHERE route = ? AND timestamp < ?", ('pagination', pagination_expiry_timestamp))
|
||||
count_pagination = cursor.fetchone()[0]
|
||||
|
||||
# Delete old non-pagination entries
|
||||
cursor.execute("DELETE FROM cache WHERE route != ? AND timestamp < ?", ('pagination', expiry_timestamp))
|
||||
|
||||
# Delete old pagination entries
|
||||
cursor.execute("DELETE FROM cache WHERE route = ? AND timestamp < ?", ('pagination', pagination_expiry_timestamp))
|
||||
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
Reference in New Issue
Block a user