Beispiel #1
0
def _executeKeyMapCmd(*cmds):
    """执行KeyMap的cmd"""
    if _REDIS_CMD_PPS_:
        _redisCmdPps('keymap', cmds)
    if __keymap_redis_conns_len == 1:
        return ftred.runCmd(__keymap_redis_conns[0], *cmds)
    else:
        idx = abs(hash(cmds[1]))
        conn = __keymap_redis_conns[idx % __keymap_redis_conns_len]
        return ftred.runCmd(conn, *cmds)
Beispiel #2
0
def executeTableCmd(roomId, tableId, *cmds):
    assert (isinstance(roomId, int) and roomId > 0)
    assert (isinstance(tableId, int) and tableId >= 0)
    cindex = int(roomId) % __table_redis_conns_len
    if _REDIS_CMD_PPS_:
        _redisCmdPps('table', cmds)
    return ftred.runCmd(__table_redis_conns[cindex], *cmds)
Beispiel #3
0
def executeTableCmd(roomId, tableId, *cmds):
    assert (isinstance(roomId, int) and roomId > 0)
    assert (isinstance(tableId, int) and tableId >= 0)
    cindex = int(roomId) % __table_redis_conns_len
    if _REDIS_CMD_PPS_:
        _redisCmdPps('table', cmds)
    return ftred.runCmd(__table_redis_conns[cindex], *cmds)
Beispiel #4
0
def executeUserLua(uid, luaName, *cmds):
    assert (isinstance(uid, int) and uid > 0)
    cindex = int(uid) % __user_redis_conns_len
    shaval = getLuaScriptsShaVal(luaName)
    if _REDIS_CMD_PPS_:
        _redisCmdPps('user', ['EVALSHA', luaName])
    return ftred.runCmd(__user_redis_conns[cindex], 'EVALSHA', shaval, *cmds)
Beispiel #5
0
def executeUserLua(uid, luaName, *cmds):
    assert (isinstance(uid, int) and uid > 0)
    cindex = int(uid) % __user_redis_conns_len
    shaval = getLuaScriptsShaVal(luaName)
    if _REDIS_CMD_PPS_:
        _redisCmdPps('user', ['EVALSHA', luaName])
    return ftred.runCmd(__user_redis_conns[cindex], 'EVALSHA', shaval, *cmds)
Beispiel #6
0
def sendUserCmd(uid, *cmds):
    """发送玩家cmd"""
    assert (isinstance(uid, int) and uid > 0)
    cindex = int(uid) % __user_redis_conns_len
    if _REDIS_CMD_PPS_:
        _redisCmdPps('user', cmds)
    return ftred.runCmd(__user_redis_conns[cindex], *cmds)
Beispiel #7
0
def executeTableLua(roomId, tableId, luaName, *cmds):
    assert (isinstance(roomId, int) and roomId > 0)
    assert (isinstance(tableId, int) and tableId >= 0)
    cindex = int(roomId) % __table_redis_conns_len
    shaval = getLuaScriptsShaVal(luaName)
    if _REDIS_CMD_PPS_:
        _redisCmdPps('table', ['EVALSHA', luaName])
    return ftred.runCmd(__table_redis_conns[cindex], 'EVALSHA', shaval, *cmds)
Beispiel #8
0
def executeTableLua(roomId, tableId, luaName, *cmds):
    assert (isinstance(roomId, int) and roomId > 0)
    assert (isinstance(tableId, int) and tableId >= 0)
    cindex = int(roomId) % __table_redis_conns_len
    shaval = getLuaScriptsShaVal(luaName)
    if _REDIS_CMD_PPS_:
        _redisCmdPps('table', ['EVALSHA', luaName])
    return ftred.runCmd(__table_redis_conns[cindex], 'EVALSHA', shaval, *cmds)
Beispiel #9
0
def getConf(confname):
    value = ftred.runCmd(redis_pool_map["config"], "GET", confname)
    if value != None:
        value = json.loads(value)
        if isinstance(value, dict):
            value = MultiDict(value)
        if isinstance(value, list):
            value = MultiList(value)
    return value
Beispiel #10
0
def getConf(confname):
    value = ftred.runCmd(redis_pool_map["config"], "GET", confname)
    if value != None:
        value = json.loads(value)
        if isinstance(value, dict):
            value = MultiDict(value)
        if isinstance(value, list):
            value = MultiList(value)
    return value
Beispiel #11
0
def loadLuaScripts(luaName, luaScript):
    oldsha = None
    for k in ftcon.redis_pool_map:
        conn = ftcon.redis_pool_map[k]
        shaval = ftred.runCmd(conn, 'script', 'load', luaScript)
        if oldsha == None:
            __luascripts[luaName] = shaval
            oldsha = shaval
        else:
            assert (oldsha == shaval)
    ftlog.info('LOADSCRIPT->', oldsha, luaName, luaScript)
    return oldsha
Beispiel #12
0
def loadLuaScripts(luaName, luaScript):
    oldsha = None
    for k in ftcon.redis_pool_map:
        conn = ftcon.redis_pool_map[k]
        shaval = ftred.runCmd(conn, 'script', 'load', luaScript)
        if oldsha == None:
            __luascripts[luaName] = shaval
            oldsha = shaval
        else:
            assert (oldsha == shaval)
    ftlog.info('LOADSCRIPT->', oldsha, luaName, luaScript)
    return oldsha
Beispiel #13
0
def executeUserLua(uid, luaName, *cmds):
    """执行用户的lua
    Redis Evalsha 命令根据给定的 sha1 校验码,执行缓存在服务器中的脚本。
    将脚本缓存到服务器的操作可以通过 SCRIPT LOAD 命令进行。
    这个命令的其他地方,比如参数的传入方式,都和 EVAL 命令一样。
    """
    assert (isinstance(uid, int) and uid > 0)
    cindex = int(uid) % __user_redis_conns_len
    shaval = getLuaScriptsShaVal(luaName)
    if _REDIS_CMD_PPS_:
        _redisCmdPps('user', ['EVALSHA', luaName])
    return ftred.runCmd(__user_redis_conns[cindex], 'EVALSHA', shaval, *cmds)
Beispiel #14
0
def preLoadLuaScript(scriptModule, luaScript):
    assert (isinstance(luaScript, (str, unicode)))
    scriptName = None
    for x in dir(scriptModule):
        if luaScript == getattr(scriptModule, x):
            scriptName = x
    assert (isinstance(scriptName, (str, unicode)))
    oldsha = None
    for k in ftcon.redis_pool_map:
        conn = ftcon.redis_pool_map[k]
        shaval = ftred.runCmd(conn, 'script', 'load', luaScript)
        if oldsha == None:
            __luascripts[scriptName] = shaval
            oldsha = shaval
        else:
            assert (oldsha == shaval)
    ftlog.info('LOADSCRIPT->', oldsha, scriptName, luaScript)
    setattr(scriptModule, scriptName, scriptName)
    return oldsha
Beispiel #15
0
def preLoadLuaScript(scriptModule, luaScript):
    assert (isinstance(luaScript, (str, unicode)))
    scriptName = None
    for x in dir(scriptModule):
        if luaScript == getattr(scriptModule, x):
            scriptName = x
    assert (isinstance(scriptName, (str, unicode)))
    oldsha = None
    for k in ftcon.redis_pool_map:
        conn = ftcon.redis_pool_map[k]
        shaval = ftred.runCmd(conn, 'script', 'load', luaScript)
        if oldsha == None:
            __luascripts[scriptName] = shaval
            oldsha = shaval
        else:
            assert (oldsha == shaval)
    ftlog.info('LOADSCRIPT->', oldsha, scriptName, luaScript)
    setattr(scriptModule, scriptName, scriptName)
    return oldsha
Beispiel #16
0
def executeRankLua(luaName, *cmds):
    """执行rank的lua"""
    if _REDIS_CMD_PPS_:
        _redisCmdPps('rank', ['EVALSHA', luaName])
    shaval = getLuaScriptsShaVal(luaName)
    return ftred.runCmd(__rank_redis_conn, 'EVALSHA', shaval, *cmds)
Beispiel #17
0
def _executeGeoLua(luaName, *cmds):
    """执行geo的lua脚本"""
    shaval = getLuaScriptsShaVal(luaName)
    if _REDIS_CMD_PPS_:
        _redisCmdPps('geo', ['EVALSHA', luaName])
    return ftred.runCmd(__geo_redis_conn, 'EVALSHA', shaval, *cmds)
Beispiel #18
0
def _executePayDataLua(luaName, *cmds):
    """执行lua脚本"""
    shaval = getLuaScriptsShaVal(luaName)
    if _REDIS_CMD_PPS_:
        _redisCmdPps('paydata', ['EVALSHA', luaName])
    return ftred.runCmd(__paydata_redis_conn, 'EVALSHA', shaval, *cmds)
Beispiel #19
0
def getConfNoCache(*cmds):
    value = ftred.runCmd(redis_pool_map["config"], *cmds)
    return value
Beispiel #20
0
def executeMixCmd(*cmds):
    """执行混合的cmd"""
    if _REDIS_CMD_PPS_:
        _redisCmdPps('mix', cmds)
    return ftred.runCmd(__mix_redis_conn, *cmds)
Beispiel #21
0
def executeRePlayCmd(*cmds):
    if _REDIS_CMD_PPS_:
        _redisCmdPps('replay', cmds)
    return ftred.runCmd(__replay_redis_conn, *cmds)
Beispiel #22
0
def executeMixCmd(*cmds):
    if _REDIS_CMD_PPS_:
        _redisCmdPps('mix', cmds)
    return ftred.runCmd(__mix_redis_conn, *cmds)
Beispiel #23
0
def executeForbiddenCmd(*cmds):
    if __forbidden_redis_conn:
        if _REDIS_CMD_PPS_:
            _redisCmdPps('forbidden', cmds)
        return ftred.runCmd(__forbidden_redis_conn, *cmds)
Beispiel #24
0
def executeWecahtFriendLua(luaName, *cmds):
    """执行微信好友lua脚本"""
    if _REDIS_CMD_PPS_:
        _redisCmdPps('friend', ['EVALSHA', luaName])
    shaval = getLuaScriptsShaVal(luaName)
    return ftred.runCmd(__wechat_friend_redis_conn, 'EVALSHA', shaval, *cmds)
Beispiel #25
0
def executeDizhuLua(luaName, *cmds):
    """执行地主lua脚本"""
    if _REDIS_CMD_PPS_:
        _redisCmdPps('dizhu', ['EVALSHA', luaName])
    shaval = getLuaScriptsShaVal(luaName)
    return ftred.runCmd(__dizhu_redis_conn, 'EVALSHA', shaval, *cmds)
Beispiel #26
0
def executeRePlayCmd(*cmds):
    """执行玩家cmd"""
    if _REDIS_CMD_PPS_:
        _redisCmdPps('replay', cmds)
    return ftred.runCmd(__replay_redis_conn, *cmds)
Beispiel #27
0
def _executeOnlineCmd(*cmds):
    """执行在线cmd"""
    if _REDIS_CMD_PPS_:
        _redisCmdPps('online', cmds)
    return ftred.runCmd(__online_redis_conn, *cmds)
Beispiel #28
0
def _executeBiCmd(*cmds):
    """执行BI cmd"""
    if _REDIS_CMD_PPS_:
        _redisCmdPps('bi', cmds)
    return ftred.runCmd(__bi_redis_conn, *cmds)
Beispiel #29
0
def executeRePlayLua(luaName, *cmds):
    if _REDIS_CMD_PPS_:
        _redisCmdPps('replay', ['EVALSHA', luaName])
    shaval = getLuaScriptsShaVal(luaName)
    return ftred.runCmd(__replay_redis_conn, 'EVALSHA', shaval, *cmds)
Beispiel #30
0
def executeUserCmd(uid, *cmds):
    assert (isinstance(uid, int) and uid > 0)
    cindex = int(uid) % __user_redis_conns_len
    if _REDIS_CMD_PPS_:
        _redisCmdPps('user', cmds)
    return ftred.runCmd(__user_redis_conns[cindex], *cmds)
Beispiel #31
0
def executeForbiddenCmd(*cmds):
    """执行禁止的cmd"""
    if __forbidden_redis_conn:
        if _REDIS_CMD_PPS_:
            _redisCmdPps('forbidden', cmds)
        return ftred.runCmd(__forbidden_redis_conn, *cmds)
Beispiel #32
0
def _executeOnlineCmd(*cmds):
    if _REDIS_CMD_PPS_:
        _redisCmdPps('online', cmds)
    return ftred.runCmd(__online_redis_conn, *cmds)
Beispiel #33
0
def executeMixLua(luaName, *cmds):
    """执行lua脚本"""
    if _REDIS_CMD_PPS_:
        _redisCmdPps('mix', ['EVALSHA', luaName])
    shaval = getLuaScriptsShaVal(luaName)
    return ftred.runCmd(__mix_redis_conn, 'EVALSHA', shaval, *cmds)
Beispiel #34
0
def _executeBiCmd(*cmds):
    if _REDIS_CMD_PPS_:
        _redisCmdPps('bi', cmds)
    return ftred.runCmd(__bi_redis_conn, *cmds)
Beispiel #35
0
def executeRePlayLua(luaName, *cmds):
    """执行玩家lua脚本"""
    if _REDIS_CMD_PPS_:
        _redisCmdPps('replay', ['EVALSHA', luaName])
    shaval = getLuaScriptsShaVal(luaName)
    return ftred.runCmd(__replay_redis_conn, 'EVALSHA', shaval, *cmds)
Beispiel #36
0
def _executeKeyMapCmd(*cmds):
    if _REDIS_CMD_PPS_:
        _redisCmdPps('keymap', cmds)
    return ftred.runCmd(__keymap_redis_conn, *cmds)
Beispiel #37
0
def _executeOnlineLua(luaName, *cmds):
    """执行在线lua"""
    shaval = getLuaScriptsShaVal(luaName)
    if _REDIS_CMD_PPS_:
        _redisCmdPps('online', ['EVALSHA', luaName])
    return ftred.runCmd(__online_redis_conn, 'EVALSHA', shaval, *cmds)
Beispiel #38
0
def _executeKeyMapLua(luaName, *cmds):
    shaval = getLuaScriptsShaVal(luaName)
    if _REDIS_CMD_PPS_:
        _redisCmdPps('keymap', ['EVALSHA', luaName])
    return ftred.runCmd(__keymap_redis_conn, 'EVALSHA', shaval, *cmds)
Beispiel #39
0
def _executeBiLua(luaName, *cmds):
    """执行Bi lua"""
    shaval = getLuaScriptsShaVal(luaName)
    if _REDIS_CMD_PPS_:
        _redisCmdPps('bi', ['EVALSHA', luaName])
    return ftred.runCmd(__bi_redis_conn, 'EVALSHA', shaval, *cmds)
Beispiel #40
0
def _executePayDataCmd(*cmds):
    if _REDIS_CMD_PPS_:
        _redisCmdPps('paydata', cmds)
    return ftred.runCmd(__paydata_redis_conn, *cmds)
Beispiel #41
0
def _executePayDataCmd(*cmds):
    """执行支付的cmd"""
    if _REDIS_CMD_PPS_:
        _redisCmdPps('paydata', cmds)
    return ftred.runCmd(__paydata_redis_conn, *cmds)
Beispiel #42
0
def _executePayDataLua(luaName, *cmds):
    shaval = getLuaScriptsShaVal(luaName)
    if _REDIS_CMD_PPS_:
        _redisCmdPps('paydata', ['EVALSHA', luaName])
    return ftred.runCmd(__paydata_redis_conn, 'EVALSHA', shaval, *cmds)
Beispiel #43
0
def _executeGeoCmd(*cmds):
    """执行geo的cmd"""
    if _REDIS_CMD_PPS_:
        _redisCmdPps('geo', cmds)
    return ftred.runCmd(__geo_redis_conn, *cmds)
Beispiel #44
0
def _executeGeoCmd(*cmds):
    if _REDIS_CMD_PPS_:
        _redisCmdPps('geo', cmds)
    return ftred.runCmd(__geo_redis_conn, *cmds)
Beispiel #45
0
def executeRankCmd(*cmds):
    """执行rank的cmd"""
    if _REDIS_CMD_PPS_:
        _redisCmdPps('rank', cmds)
    return ftred.runCmd(__rank_redis_conn, *cmds)
Beispiel #46
0
def _executeGeoLua(luaName, *cmds):
    shaval = getLuaScriptsShaVal(luaName)
    if _REDIS_CMD_PPS_:
        _redisCmdPps('geo', ['EVALSHA', luaName])
    return ftred.runCmd(__geo_redis_conn, 'EVALSHA', shaval, *cmds)
Beispiel #47
0
def executeWechatFriendCmd(*cmds):
    """执行微信好友cmd"""
    if _REDIS_CMD_PPS_:
        _redisCmdPps('friend', cmds)
    return ftred.runCmd(__wechat_friend_redis_conn, *cmds)
Beispiel #48
0
def executeRankCmd(*cmds):
    if _REDIS_CMD_PPS_:
        _redisCmdPps('rank', cmds)
    return ftred.runCmd(__rank_redis_conn, *cmds)
Beispiel #49
0
def executeDizhuCmd(*cmds):
    """执行地主cmd"""
    if _REDIS_CMD_PPS_:
        _redisCmdPps('dizhu', cmds)
    return ftred.runCmd(__dizhu_redis_conn, *cmds)
Beispiel #50
0
def executeDizhuCmd(*cmds):
    if _REDIS_CMD_PPS_:
        _redisCmdPps('dizhu', cmds)
    return ftred.runCmd(__dizhu_redis_conn, *cmds)
Beispiel #51
0
def doRedis(poolname, *argl, **argd):
    conn = ftcon.redis_pool_map.get(poolname, None)
    if conn == None:
        raise FTException("doRedis:poolname [" + str(poolname) +
                          "] undefined.")
    return ftred.runCmd(conn, *argl, **argd)
Beispiel #52
0
def executeDizhuLua(luaName, *cmds):
    if _REDIS_CMD_PPS_:
        _redisCmdPps('dizhu', ['EVALSHA', luaName])
    shaval = getLuaScriptsShaVal(luaName)
    return ftred.runCmd(__dizhu_redis_conn, 'EVALSHA', shaval, *cmds)
Beispiel #53
0
def getConfNoCache(*cmds):
    value = ftred.runCmd(redis_pool_map["config"], *cmds)
    return value
Beispiel #54
0
def doRedis(poolname, *argl, **argd):
    conn = ftcon.redis_pool_map.get(poolname, None)
    if conn == None:
        raise FTException("doRedis:poolname [" + str(poolname) + "] undefined.")
    return ftred.runCmd(conn, *argl, **argd)