confluent-schema-registry icon indicating copy to clipboard operation
confluent-schema-registry copied to clipboard

Is there any caching in place?

Open krukru opened this issue 5 years ago • 4 comments

Is there any schema caching (memoization) in the SchemaRegistry client? For example, will the following snippet generate more than 1 API call?

let response: any = SchemaRegistry.getLatestSchemaId("foo"); // calls API
response = SchemaRegistry.getLatestSchemaId("foo"); // return cached value, does not call API

krukru avatar Jan 24 '20 15:01 krukru

If anyone is interested in the answer, encode, decode and getSchema do cache the schema by id and do not make new API calls for schemas they already know.

getLatestSchemaId obviously should not cache, since you can never know if the latest schema updated in between calls.

getRegistryId and register also do not cache, but I think they could do so. If you get the schema ID for a tuple (subject, version), that will never change (unless version value is "latest", in which case you again cannot cache anything). Also, registering the same schema under the same subject multiple times will just yield in the same schema ID (idempotent operation), or at least I think it will.

I think it would be good to mention this in the docs and in the usage examples, or even better - consider implementing the memoization for getRegistryId and register What are your thoughts on this?

krukru avatar Jan 27 '20 01:01 krukru

I think it would be good to mention this in the docs and in the usage examples, or even better - consider implementing the memoization for getRegistryId and register What are your thoughts on this?

I have no objections 🙂Contributions to the documentation would be awesome and I'm always available for review 👍

erikengervall avatar Feb 08 '20 22:02 erikengervall

Has this been implemented

gaukharaya avatar Jul 10 '21 11:07 gaukharaya

Also, registering the same schema under the same subject multiple times will just yield in the same schema ID (idempotent operation), or at least I think it will.

It will.

betamatt avatar May 16 '23 14:05 betamatt