Skip to content

Commit

Permalink
minor changes to support valkey (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
catcherwong authored Sep 28, 2024
1 parent 7d41abd commit 7a5d858
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/RDBCli/Callbacks/MemoryCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,17 @@ public void AuxField(byte[] key, byte[] value)
else if (keyStr.Equals("redis-bits"))
{
_rdbDataInfo.RedisBits = RedisRdbObjectHelper.ConvertBytesToInteger(value);
_rdbDataInfo.RedisType = "Redis";
}
else if (keyStr.Equals("ctime"))
{
_rdbDataInfo.CTime = RedisRdbObjectHelper.ConvertBytesToInteger(value);
}
else if (keyStr.Equals("valkey-ver"))
{
_rdbDataInfo.RedisVer = System.Text.Encoding.UTF8.GetString(value);
_rdbDataInfo.RedisType = "Valkey";
}
}

public void DbSize(uint dbSize, uint expiresSize)
Expand Down
2 changes: 2 additions & 0 deletions src/RDBCli/Commands/MemoryCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ public class MemoryAnslysisResult
public int count { get; set; }
public int rdbVer { get; set; }
public string redisVer { get; set; }
public string redisType { get; set; }
public long redisBits { get; set; }
public int expCount { get; set; }
public int permCount { get; set; }
Expand All @@ -265,6 +266,7 @@ internal static MemoryAnslysisResult BuildBasicFromRdbDataInfo(RdbDataInfo rdbDa
redisVer = string.IsNullOrWhiteSpace(rdbDataInfo.RedisVer) ? CommonHelper.GetFuzzyRedisVersion(rdbDataInfo.RdbVer) : rdbDataInfo.RedisVer,
redisBits = rdbDataInfo.RedisBits,
functions = rdbDataInfo.Functions,
redisType = rdbDataInfo.RedisType,
};

return result;
Expand Down
4 changes: 2 additions & 2 deletions src/RDBCli/Helpers/CommonHelper.Const.cs

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/RDBCli/Stats/RdbDataInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,10 @@ internal class RdbDataInfo
/// The information about the functions and libraries
/// </summary>
public List<FunctionsRecord> Functions { get; set; } = new List<FunctionsRecord>();

/// <summary>
/// The information about the redis type, Redis or Valkey
/// </summary>
public string RedisType { get; set; } = "Redis";
}
}
3 changes: 2 additions & 1 deletion src/RDBCli/Tpl/tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <h3>
RDB Version: <b id="rdbVer"></b>
</div>
<div class="lead display-7">
Redis Version: <b id="redisVer"></b>
<label id="redisType">Redis</label> Version: <b id="redisVer"></b>
</div>
</div>
</div>
Expand Down Expand Up @@ -168,6 +168,7 @@ <h3>

$('#rdbVer').text(cliData.rdbVer);
$('#redisVer').text(cliData.redisVer);
$('#redisType').text(cliData.redisType);
$('#totalKeyBytes').text(formatBytes(cliData.usedMem));
$('#totalKeyNum').text(formatNumber(cliData.count));
$('#expKeyNum').text(formatNumber(cliData.expCount));
Expand Down
7 changes: 3 additions & 4 deletions src/RDBParser/Constant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ public static class RdbVersion
public const int Min = 1;

// Redis 6.2.14 9
// Redis 7.0-rc1 10
// Redis 7.0.15 10
// Redis 7.2-rc1 11
// Redis 7.2.4 11
// Redis 7.0-rc1~~7.0.15 10
// Redis 7.2-rc1~~7.4.0 11
// Valkey 7.2.4-rc1~~8.0.0 11
public const int Max = 11;
}

Expand Down

0 comments on commit 7a5d858

Please sign in to comment.