Skip to content

Commit c9b0be4

Browse files
committed
Cleanup code a bit
1 parent 63894f5 commit c9b0be4

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

API/Realtime/RedisSubscriberService.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,19 @@ private void HandleKeyExpired(RedisChannel _, RedisValue message)
6363
}
6464

6565
// ToString here just casts the underlying object to a string
66-
//if (message.ToString().Split(':', 2) is not [{ } guid, { } name]) return;
67-
6866
var messageString = message.ToString();
6967
var messageSpan = messageString.AsSpan();
7068

69+
// We always expect TypeName:GUID right now, and this wont throw if there is more split results than expected
70+
// We also dont need to check for its length after, since we pre-stackalloc
7171
Span<Range> split = stackalloc Range[2];
7272
messageSpan.Split(split, ':');
73-
74-
if (split.Length != 2)
75-
{
76-
if(_logger.IsEnabled(LogLevel.Debug)) _logger.LogDebug("Received expired key with invalid format for hub offline status: {MessageValue}", messageString);
77-
return;
78-
}
7973

74+
// Data structure is TypeName:GUID
8075
var typeNameSpan = messageSpan[split[0]];
8176
var guidSpan = messageSpan[split[1]];
8277

78+
// Check what type of expired key this is
8379
if (typeNameSpan.SequenceEqual(typeof(DeviceOnline).FullName))
8480
{
8581
if (!Guid.TryParse(guidSpan, out var id))

0 commit comments

Comments
 (0)