@@ -64,8 +64,8 @@ public class CachedSchemaRegistryClient : ISchemaRegistryClient, IDisposable
64
64
private int latestCacheTtlSecs ;
65
65
private readonly Dictionary < int , Schema > schemaById = new Dictionary < int , Schema > ( ) ;
66
66
67
- private readonly Dictionary < string /*subject*/ , Dictionary < string , int > > idBySchemaBySubject =
68
- new Dictionary < string , Dictionary < string , int > > ( ) ;
67
+ private readonly Dictionary < string /*subject*/ , Dictionary < Schema , int > > idBySchemaBySubject =
68
+ new Dictionary < string , Dictionary < Schema , int > > ( ) ;
69
69
70
70
private readonly Dictionary < string /*subject*/ , Dictionary < int , RegisteredSchema > > schemaByVersionBySubject =
71
71
new Dictionary < string , Dictionary < int , RegisteredSchema > > ( ) ;
@@ -430,24 +430,24 @@ public async Task<int> GetSchemaIdAsync(string subject, Schema schema, bool norm
430
430
await cacheMutex . WaitAsync ( ) . ConfigureAwait ( continueOnCapturedContext : false ) ;
431
431
try
432
432
{
433
- if ( ! this . idBySchemaBySubject . TryGetValue ( subject , out Dictionary < string , int > idBySchema ) )
433
+ if ( ! this . idBySchemaBySubject . TryGetValue ( subject , out Dictionary < Schema , int > idBySchema ) )
434
434
{
435
- idBySchema = new Dictionary < string , int > ( ) ;
435
+ idBySchema = new Dictionary < Schema , int > ( ) ;
436
436
this . idBySchemaBySubject . Add ( subject , idBySchema ) ;
437
437
}
438
438
439
439
// TODO: The following could be optimized in the usual case where idBySchema only
440
440
// contains very few elements and the schema string passed in is always the same
441
441
// instance.
442
442
443
- if ( ! idBySchema . TryGetValue ( schema . SchemaString , out int schemaId ) )
443
+ if ( ! idBySchema . TryGetValue ( schema , out int schemaId ) )
444
444
{
445
445
CleanCacheIfFull ( ) ;
446
446
447
447
// throws SchemaRegistryException if schema is not known.
448
448
var registeredSchema = await restService . LookupSchemaAsync ( subject , schema , true , normalize )
449
449
. ConfigureAwait ( continueOnCapturedContext : false ) ;
450
- idBySchema [ schema . SchemaString ] = registeredSchema . Id ;
450
+ idBySchema [ schema ] = registeredSchema . Id ;
451
451
schemaById [ registeredSchema . Id ] = registeredSchema . Schema ;
452
452
schemaId = registeredSchema . Id ;
453
453
}
@@ -467,23 +467,23 @@ public async Task<int> RegisterSchemaAsync(string subject, Schema schema, bool n
467
467
await cacheMutex . WaitAsync ( ) . ConfigureAwait ( continueOnCapturedContext : false ) ;
468
468
try
469
469
{
470
- if ( ! this . idBySchemaBySubject . TryGetValue ( subject , out Dictionary < string , int > idBySchema ) )
470
+ if ( ! this . idBySchemaBySubject . TryGetValue ( subject , out Dictionary < Schema , int > idBySchema ) )
471
471
{
472
- idBySchema = new Dictionary < string , int > ( ) ;
472
+ idBySchema = new Dictionary < Schema , int > ( ) ;
473
473
this . idBySchemaBySubject [ subject ] = idBySchema ;
474
474
}
475
475
476
476
// TODO: This could be optimized in the usual case where idBySchema only
477
477
// contains very few elements and the schema string passed in is always
478
478
// the same instance.
479
479
480
- if ( ! idBySchema . TryGetValue ( schema . SchemaString , out int schemaId ) )
480
+ if ( ! idBySchema . TryGetValue ( schema , out int schemaId ) )
481
481
{
482
482
CleanCacheIfFull ( ) ;
483
483
484
484
schemaId = await restService . RegisterSchemaAsync ( subject , schema , normalize )
485
485
. ConfigureAwait ( continueOnCapturedContext : false ) ;
486
- idBySchema [ schema . SchemaString ] = schemaId ;
486
+ idBySchema [ schema ] = schemaId ;
487
487
}
488
488
489
489
return schemaId ;
0 commit comments