This commit is contained in:
wuaho 2021-05-11 16:19:56 +08:00
parent f55dbdc134
commit 9597bac720
3 changed files with 20 additions and 8 deletions

4
app.py
View File

@ -3,7 +3,7 @@ from multiprocessing import Process
from settings import settings
from v2 import *
from v2.struct_cache import StructCacheFile
from v2.struct_cache import StructCacheFile, StructCacheRedis
class XProcess(Process):
@ -16,7 +16,7 @@ class XProcess(Process):
def run(self):
db_client = CK(**settings.CK_CONFIG)
sketch = Sketch(db_client, StructCacheFile())
sketch = Sketch(db_client, StructCacheRedis())
handler_event = HandlerEvent(db_client, settings.GAME, self.ipsearch)
handler_user = HandlerUser(db_client, settings.GAME)
transmitter = Transmitter(db_client, settings.GAME, sketch, self.lock)

View File

@ -20,12 +20,13 @@ class Config:
# 游戏数据库名
GAME = 'shjy'
# REDIS_CONF = {
# 'host': '192.168.0.161',
# 'port': 6379,
# 'password': 'd1Gh*zp5',
# 'ck': 10 # ck
# }
REDIS_CONF = {
'host': '192.168.0.161',
'port': 6379,
'password': 'd1Gh*zp5',
'db': 1, # 存表结构
'decode_responses':True
}
class Debug(Config):

View File

@ -1,4 +1,7 @@
import json
import redis
from settings import settings
class StructCacheFile:
@ -9,3 +12,11 @@ class StructCacheFile:
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))