Commit c4817e410a63993ada34754453a9bc44f655233e
1 parent
b09f4672
不要了
Showing
3 changed files
with
0 additions
and
92 deletions
Show diff stats
src/python/adv_season.py deleted
src/python/redisCommon.py deleted
| @@ -1,78 +0,0 @@ | @@ -1,78 +0,0 @@ | ||
| 1 | -from redis import Redis | ||
| 2 | -import msgpack | ||
| 3 | - | ||
| 4 | -redisConf = { | ||
| 5 | - "host" : "127.0.0.1", | ||
| 6 | - "port" : 6100, | ||
| 7 | - "db" : 1, | ||
| 8 | - "password" : None, | ||
| 9 | -} | ||
| 10 | - | ||
| 11 | - | ||
| 12 | -def numberUnpack(n) : | ||
| 13 | - if isinstance(n, bytes) : | ||
| 14 | - try: | ||
| 15 | - return int(n) | ||
| 16 | - except ValueError: | ||
| 17 | - try: | ||
| 18 | - return float(n) | ||
| 19 | - except ValueError: | ||
| 20 | - pass | ||
| 21 | - return n.decode() | ||
| 22 | - else : | ||
| 23 | - return n | ||
| 24 | - | ||
| 25 | -def stringUnpack(s) : | ||
| 26 | - if isinstance(s, bytes) : | ||
| 27 | - return n.decode() | ||
| 28 | - else : | ||
| 29 | - return s | ||
| 30 | - | ||
| 31 | -def tableUnpack(t) : | ||
| 32 | - if isinstance(t, bytes) : | ||
| 33 | - return msgpack.unpackb(t, raw = False) #解包 | ||
| 34 | - else : | ||
| 35 | - return t | ||
| 36 | - | ||
| 37 | -redisUnpack = { | ||
| 38 | - "number" : numberUnpack, | ||
| 39 | - "string" : stringUnpack, | ||
| 40 | - "table" : tableUnpack, | ||
| 41 | - "default" : numberUnpack, | ||
| 42 | -} | ||
| 43 | -def commonPack(w) : | ||
| 44 | - return w | ||
| 45 | - | ||
| 46 | -def tablePack(t): | ||
| 47 | - return msgpack.packb(t, use_bin_type = True) | ||
| 48 | - | ||
| 49 | -redisPack = { | ||
| 50 | - "default" : commonPack, | ||
| 51 | - "table" : tablePack, | ||
| 52 | -} | ||
| 53 | - | ||
| 54 | - | ||
| 55 | - | ||
| 56 | - | ||
| 57 | -redis = Redis( | ||
| 58 | - host = redisConf["host"], | ||
| 59 | - port = redisConf["port"], | ||
| 60 | - db = redisConf["db"], | ||
| 61 | - password = redisConf["password"] | ||
| 62 | -) | ||
| 63 | - | ||
| 64 | -pipe = redis.pipeline() | ||
| 65 | - | ||
| 66 | -def decode(w, t = "default"): | ||
| 67 | - return redisUnpack[t](w) | ||
| 68 | - | ||
| 69 | -def encode(w, t = "default") : | ||
| 70 | - return redisPack[t](w) | ||
| 71 | - | ||
| 72 | - | ||
| 73 | - | ||
| 74 | - | ||
| 75 | - | ||
| 76 | - | ||
| 77 | - | ||
| 78 | - |
src/python/requirements.txt deleted