import json
import redis

from settings import settings


class StructCacheFile:
    def __init__(self):
        pass

    @staticmethod
    def update(db, tb, data):
        with open(f'{db}_{tb}.json', 'w') as f:
            json.dump(data, f)


class StructCacheRedis:
    def __init__(self, rdb):
        self.rdb = rdb

    def update(self, db, tb, data):
        self.rdb.set(f'{db}_{tb}', json.dumps(data))
