1
This commit is contained in:
parent
f55dbdc134
commit
9597bac720
4
app.py
4
app.py
@ -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)
|
||||
|
13
settings.py
13
settings.py
@ -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):
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user