session cleanup via background job

Signed-off-by: chandi Langecker <git@chandi.it>
This commit is contained in:
chandi Langecker
2022-11-10 17:01:06 +01:00
parent d7919497b6
commit 0ea384d1e5
5 changed files with 68 additions and 0 deletions

View File

@@ -64,4 +64,10 @@ class SessionMapper extends QBMapper {
return $this->findEntities($qb);
}
public function deleteInactive(): int {
$qb = $this->db->getQueryBuilder();
$qb->delete($this->getTableName())
->where($qb->expr()->lt('last_contact', $qb->createNamedParameter(time() - SessionService::SESSION_VALID_TIME)));
return $qb->executeStatement();
}
}