public function clean(string $sessionId, $daemon = false): bool
    {
        //we sent the session id to the seassion daemon cleaner
        if (!$daemon) {
            try {
                $queue = $this->getDI()->getQueue();
                $queue->putInTube(getenv('SESSION_QUEUE'), $sessionId);
            } catch (Throwable $e) {
                //we get here if beanstalkd is down, we are moving to rabbitmq
                $this->di->getLog()->error($e->getMessage());
                return false;
            }

            return true;
        }

        $cache = $this->getDI()->getRedis();

        //
        // Delete expired sessions
        //
        $sql = "DELETE FROM  Baka\Auth\Models\Sessions
            WHERE time < :session_time:
                AND id <> :session_id: ";

        $sessionTime = time() - (int) $this->getDI()->getConfig()->jwt->payload->exp;

        $params = [
            'session_time' => $sessionTime,
            'session_id' => $sessionId,
        ];

        $result = $this->getModelsManager()->executeQuery($sql, $params);

        //
        // Delete expired keys
        //
        $sql = 'DELETE FROM Baka\Auth\Models\SessionKeys
                WHERE last_login < :last_login: ';

        $last_login = time() - (2 * (int)$this->getDI()->getConfig()->jwt->payload->exp);

        $params = ['last_login' => $last_login];

        $result = $this->getModelsManager()->executeQuery($sql, $params);

        return true;
    }