Class: AvroTurf::CachedConfluentSchemaRegistry
- Inherits:
-
Object
- Object
- AvroTurf::CachedConfluentSchemaRegistry
- Defined in:
- lib/avro_turf/cached_confluent_schema_registry.rb
Overview
Caches registrations and lookups to the schema registry in memory.
Instance Method Summary collapse
- #fetch(id) ⇒ Object
-
#initialize(upstream) ⇒ CachedConfluentSchemaRegistry
constructor
A new instance of CachedConfluentSchemaRegistry.
- #register(subject, schema) ⇒ Object
Constructor Details
#initialize(upstream) ⇒ CachedConfluentSchemaRegistry
Returns a new instance of CachedConfluentSchemaRegistry.
6 7 8 9 10 |
# File 'lib/avro_turf/cached_confluent_schema_registry.rb', line 6 def initialize(upstream) @upstream = upstream @schemas_by_id = {} @ids_by_schema = {} end |
Instance Method Details
#fetch(id) ⇒ Object
20 21 22 |
# File 'lib/avro_turf/cached_confluent_schema_registry.rb', line 20 def fetch(id) @schemas_by_id[id] ||= @upstream.fetch(id) end |
#register(subject, schema) ⇒ Object
24 25 26 |
# File 'lib/avro_turf/cached_confluent_schema_registry.rb', line 24 def register(subject, schema) @ids_by_schema[subject + schema.to_s] ||= @upstream.register(subject, schema) end |