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