diff --git a/session_db/pg_session_store.py b/session_db/pg_session_store.py index ad47eb4fec0..21c1776bf0c 100644 --- a/session_db/pg_session_store.py +++ b/session_db/pg_session_store.py @@ -149,6 +149,19 @@ def vacuum(self, max_lifetime=http.SESSION_LIFETIME): (f"{max_lifetime} seconds",), ) + @with_lock + @with_cursor + def delete_from_identifiers(self, identifiers: list[str]) -> None: + for identifier in identifiers: + if not sessions._sha1_re.match(identifier): + raise ValueError( + "Identifier format incorrect, " + "did you pass in a string instead of a list?" + ) + self._cr.execute( + "DELETE FROM http_sessions WHERE sid LIKE %s||'%%'", (identifier,) + ) + _original_session_store = http.root.__class__.session_store