'Purge remembered entries if the config has changed.'

@plugin.priority(0)
def on_task_start(self, task, config):

    with Session() as session:
        old_task = session.query(RememberTask).filter((RememberTask.name == task.name)).first()
        if ((not task.is_rerun) and old_task and task.config_modified):
            log.debug(u'Task    config    has    changed    since    last    run,    purging    remembered    entries.')
            session.delete(old_task)
            old_task = None
        if (not old_task):
            session.add(RememberTask(name=task.name))
        elif (not task.is_rerun):
            deleted = session.query(RememberEntry).filter((RememberEntry.task_id == old_task.id)).filter((RememberEntry.expires < datetime.now())).delete()
            if deleted:
                log.debug((u'%s    entries    have    expired    from    remember_rejected    table.' % deleted))
                task.config_changed()
