Class: AvroTurf::CachedConfluentSchemaRegistry

Inherits:
Object
  • Object
show all
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

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