Exemplo n.º 1
0
 private static void SaveTo()
 {
     try
     {
         var client = RedisConnectionPool.Pop();
         try
         {
             byte[] data = ProtoBufUtils.Serialize(_globalSession);
             client.Set(sessionRedisKey, data);
         }
         finally
         {
             RedisConnectionPool.Put(client);
         }
     }
     catch (Exception er)
     {
         TraceLog.WriteError("Save session to redis faild,{0}", er);
     }
 }
Exemplo n.º 2
0
 private static void LoadUnLineData()
 {
     try
     {
         var client = RedisConnectionPool.Pop();
         try
         {
             byte[] data = client.Get <byte[]>(sessionRedisKey);
             var    temp = ProtoBufUtils.Deserialize <ConcurrentDictionary <Guid, GameSession> >(data);
             if (temp != null)
             {
                 _globalSession = temp;
             }
         }
         finally
         {
             RedisConnectionPool.Put(client);
         }
     }
     catch (Exception er)
     {
         TraceLog.WriteError("Load GameSession from redis faild,{0}", er);
     }
 }