private string getFormatValue(string type) { string text = ""; if (currentRedisDatabase == null) { return(""); } CSRedis.RedisClient redisClient = currentRedisDatabase.ParentServer.RedisClient; string key = currentRedisKey.Key; string[] fields = null; try { fields = redisClient.HKeys(key); }catch (Exception e) { log.Error(e.Message); } string field = fields != null && fields.Length > 0 ? fields[0] : null; if (field != null) { text = redisClient.HGet(key, field); } else { text = redisClient.Get(key); } Debug.WriteLine("json:" + text); switch (type) { case "Json": try { JsonSerializer jsonSerializer = new JsonSerializer(); System.IO.StringWriter stringWriter = new System.IO.StringWriter(); JsonTextWriter jsonTextWriter = new JsonTextWriter(stringWriter); jsonTextWriter.Formatting = Formatting.Indented; jsonTextWriter.Indentation = 4; jsonTextWriter.IndentChar = ' '; object jsonObj = JsonConvert.DeserializeObject(text); jsonSerializer.Serialize(jsonTextWriter, jsonObj); text = stringWriter.ToString(); stringWriter.Close(); jsonTextWriter.Close(); }catch (Exception e) { log.Error("json serialize faild [" + e.Message + "]"); } break; default: break; } return(text); }
public string StringGet(string key) { return(client.Get(AddKeyPrefix(key))); }