to_ck/v2/struct_cache.py
2021-05-11 16:19:56 +08:00

23 lines
440 B
Python

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):
self.rdb = redis.Redis(**settings.REDIS_CONF)
def update(self, db, tb, data):
self.rdb.set(f'{db}_{tb}', json.dumps(data))