#!/usr/bin/env python
from config import *
from clients import  conn_redis


""" run once when stopped service every time

1. clear usr-agent map key
2. clear agent-user map key
3. clear user-logic map
4. clear logic-user map

"""
key_prefixes = [
    rds_key_map_agent_user,
    rds_key_map_logic_user,
    rds_key_map_user_agent,
    rds_key_map_user_logic,
]


def main():
    rds = conn_redis(rds_host, rds_port, '', rds_password, rds_db_game)
    for key in key_prefixes:
        kl = rds.keys('{}*'.format(key))
        print('deleting keys:', kl)
        rds.delete(kl)
    rds.close()


if __name__ == '__main__':
    main()
    print('done')
