def METHOD_NAME(self, task, config):
    """Purge remembered entries if the config has changed."""
    with Session() as session:
        # See if the task has changed since last run
        old_task = (
            session.query(db.RememberTask).filter(db.RememberTask.name == task.name).first()
        )
        if not task.is_rerun and old_task and task.config_modified:
            logger.debug('Task config has changed since last run, purging remembered entries.')
            session.delete(old_task)
            old_task = None
        if not old_task:
            # Create this task in the db if not present
            session.add(db.RememberTask(name=task.name))
        elif not task.is_rerun:
            # Delete expired items if this is not a rerun
            deleted = (
                session.query(db.RememberEntry)
                .filter(db.RememberEntry.task_id == old_task.id)
                .filter(db.RememberEntry.expires < datetime.now())
                .delete()
            )
            if deleted:
                logger.debug('{} entries have expired from remember_rejected table.', deleted)
                task.config_changed()