Skip to content

Commit 1fae1f6

Browse files
committed
Use versioned cache keys
1 parent f59c0e0 commit 1fae1f6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/ModelContextProtocol.Core/Server/DistributedCacheEventStreamStore.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,18 @@ public ValueTask<ISseEventStreamWriter> CreateStreamAsync(SseEventStreamOptions
8787
/// <summary>
8888
/// Provides methods for generating cache keys.
8989
/// </summary>
90+
/// <remarks>
91+
/// Cache keys are versioned to allow format changes without conflicts with existing entries.
92+
/// When the cache format changes, increment <see cref="Version"/> to invalidate old entries.
93+
/// </remarks>
9094
internal static class CacheKeys
9195
{
92-
private const string Prefix = "mcp:sse:";
96+
/// <summary>
97+
/// The current cache key version. Increment this when changing the cache format
98+
/// to ensure old entries are ignored.
99+
/// </summary>
100+
private const string Version = "v1";
101+
private const string Prefix = $"mcp:sse:{Version}:";
93102

94103
public static string StreamMetadata(string sessionId, string streamId) =>
95104
$"{Prefix}meta:{sessionId}:{streamId}";

0 commit comments

Comments
 (0)