diff --git a/src/RDBCli/Callbacks/KeysOnlyCallback.cs b/src/RDBCli/Callbacks/KeysOnlyCallback.cs index ad9f26d..e37a776 100644 --- a/src/RDBCli/Callbacks/KeysOnlyCallback.cs +++ b/src/RDBCli/Callbacks/KeysOnlyCallback.cs @@ -183,5 +183,9 @@ public void ZAdd(byte[] key, double score, byte[] member) public void SetIdleOrFreq(int val) { } + + public void SetSlotInfo(ulong slotId, ulong slotSize, ulong expireSlotSize) + { + } } } diff --git a/src/RDBCli/Callbacks/MemoryCallback.cs b/src/RDBCli/Callbacks/MemoryCallback.cs index 3f24c57..fc690f6 100644 --- a/src/RDBCli/Callbacks/MemoryCallback.cs +++ b/src/RDBCli/Callbacks/MemoryCallback.cs @@ -483,5 +483,9 @@ public void SetIdleOrFreq(int val) { _idleOrFreq = val; } + + public void SetSlotInfo(ulong slotId, ulong slotSize, ulong expireSlotSize) + { + } } } diff --git a/src/RDBParser/BinaryReaderRDBParser.cs b/src/RDBParser/BinaryReaderRDBParser.cs index f97d7ff..7cbbd41 100644 --- a/src/RDBParser/BinaryReaderRDBParser.cs +++ b/src/RDBParser/BinaryReaderRDBParser.cs @@ -88,6 +88,15 @@ public void Parse(string path) } } + if (opType == Constant.OpCode.SLOTINFO) + { + var slotId = br.ReadLength(); + var slotSize = br.ReadLength(); + var expireSlotSize = br.ReadLength(); + _callback.SetSlotInfo(slotId, slotSize, expireSlotSize); + continue; + } + if (opType == Constant.OpCode.SELECTDB) { if (!isFirstDb) diff --git a/src/RDBParser/Callbacks/DefaultConsoleReaderCallBack.cs b/src/RDBParser/Callbacks/DefaultConsoleReaderCallBack.cs index 16cc8bd..a139a06 100644 --- a/src/RDBParser/Callbacks/DefaultConsoleReaderCallBack.cs +++ b/src/RDBParser/Callbacks/DefaultConsoleReaderCallBack.cs @@ -91,6 +91,11 @@ public void SetIdleOrFreq(int val) Console.WriteLine($"SetIdleOrFreq, val={val}"); } + public void SetSlotInfo(ulong slotId, ulong slotSize, ulong expireSlotSize) + { + Console.WriteLine($"SetSlotInfo, slotId={slotId}, slotSize={slotSize}, expireSlotSize={expireSlotSize}"); + } + public void StartDatabase(int database) { Console.WriteLine($"Start database = {database}"); diff --git a/src/RDBParser/Callbacks/IReaderCallback.cs b/src/RDBParser/Callbacks/IReaderCallback.cs index 7572d88..fdf038e 100644 --- a/src/RDBParser/Callbacks/IReaderCallback.cs +++ b/src/RDBParser/Callbacks/IReaderCallback.cs @@ -223,5 +223,13 @@ public interface IReaderCallback /// /// void SetIdleOrFreq(int val); + + /// + /// Record Slot Info + /// + /// + /// + /// + void SetSlotInfo(ulong slotId, ulong slotSize, ulong expireSlotSize); } } diff --git a/src/RDBParser/Callbacks/NoOpReaderCallBack.cs b/src/RDBParser/Callbacks/NoOpReaderCallBack.cs index 60f9764..4b8ec35 100644 --- a/src/RDBParser/Callbacks/NoOpReaderCallBack.cs +++ b/src/RDBParser/Callbacks/NoOpReaderCallBack.cs @@ -72,6 +72,10 @@ public void SetIdleOrFreq(int val) { } + public void SetSlotInfo(ulong slotId, ulong slotSize, ulong expireSlotSize) + { + } + public void StartDatabase(int database) { } diff --git a/src/RDBParser/Constant.cs b/src/RDBParser/Constant.cs index ef72073..9286008 100755 --- a/src/RDBParser/Constant.cs +++ b/src/RDBParser/Constant.cs @@ -1,4 +1,6 @@ -namespace RDBParser +using System.Dynamic; + +namespace RDBParser { public static class Constant { @@ -31,6 +33,10 @@ public static class MagicCount public static class OpCode { + /// + /// Individual slot info, such as slot id and size (cluster mode only). + /// + public const int SLOTINFO = 244; public const int FUNCTION2 = 245; public const int FUNCTION = 246; public const int MODULE_AUX = 247; diff --git a/tests/RDBParserTests/TestReaderCallback.cs b/tests/RDBParserTests/TestReaderCallback.cs index 7363a04..4d54c0d 100644 --- a/tests/RDBParserTests/TestReaderCallback.cs +++ b/tests/RDBParserTests/TestReaderCallback.cs @@ -346,5 +346,10 @@ public void SetIdleOrFreq(int val) { _idleOrFreq = val; } + + public void SetSlotInfo(ulong slotId, ulong slotSize, ulong expireSlotSize) + { + System.Diagnostics.Trace.WriteLine($"{slotId}, {slotSize}, {expireSlotSize}"); + } } } \ No newline at end of file