from redis import Redis
from scripts.config.json_reader import application_config
from scripts.util.logger import logger


class previousTag:
    def __init__(self):
        self.host = application_config['redis']['host']
        self.port = int(application_config['redis']['port'])
        self.db = application_config['redis']['tags_data']

    def get_data(self):
        try:
            live_tags_db_object = Redis(
                host=self.host,
                port=self.port,
                db=self.db,
                decode_responses=True,
            )
            return live_tags_db_object
        except Exception as e:
            logger.exception(f'Error in connecting to Redis : {es}')
            raise
