class AvroTurf::InMemoryCache

A cache for the CachedConfluentSchemaRegistry. Simply stores the schemas and ids in in-memory hashes.

Public Class Methods

new() click to toggle source
# File lib/avro_turf/in_memory_cache.rb, line 4
def initialize
  @schemas_by_id = {}
  @ids_by_schema = {}
  @schema_by_subject_version = {}
  @data_by_schema = {}
end

Public Instance Methods

lookup_by_id(id) click to toggle source
# File lib/avro_turf/in_memory_cache.rb, line 11
def lookup_by_id(id)
  @schemas_by_id[id]
end
lookup_by_schema(subject, schema) click to toggle source
# File lib/avro_turf/in_memory_cache.rb, line 19
def lookup_by_schema(subject, schema)
  key = [subject, schema]
  @ids_by_schema[key]
end
lookup_by_version(subject, version) click to toggle source
# File lib/avro_turf/in_memory_cache.rb, line 41
def lookup_by_version(subject, version)
  key = "#{subject}#{version}"
  @schema_by_subject_version[key]
end
lookup_data_by_schema(subject, schema) click to toggle source
# File lib/avro_turf/in_memory_cache.rb, line 24
def lookup_data_by_schema(subject, schema)
  key = [subject, schema]
  @data_by_schema[key]
end
store_by_id(id, schema) click to toggle source
# File lib/avro_turf/in_memory_cache.rb, line 15
def store_by_id(id, schema)
  @schemas_by_id[id] = schema
end
store_by_schema(subject, schema, id) click to toggle source
# File lib/avro_turf/in_memory_cache.rb, line 29
def store_by_schema(subject, schema, id)
  key = [subject, schema]
  @ids_by_schema[key] = id
end
store_by_version(subject, version, schema) click to toggle source
# File lib/avro_turf/in_memory_cache.rb, line 46
def store_by_version(subject, version, schema)
  key = "#{subject}#{version}"
  @schema_by_subject_version[key] = schema
end
store_data_by_schema(subject, schema, data) click to toggle source
# File lib/avro_turf/in_memory_cache.rb, line 34
def store_data_by_schema(subject, schema, data)
  return unless data

  key = [subject, schema]
  @data_by_schema[key] = data
end