Sha256: ccb8480aa1a520a5fa3e7d0acb0bf772ccb9a5ffaa67bad5e97046dfba00c533

Contents?: true

Size: 838 Bytes

Versions: 7

Compression:

Stored size: 838 Bytes

Contents

# A cache for the CachedConfluentSchemaRegistry.
# Simply stores the schemas and ids in in-memory hashes.
class AvroTurf::InMemoryCache

  def initialize
    @schemas_by_id = {}
    @ids_by_schema = {}
    @schema_by_subject_version = {}
  end

  def lookup_by_id(id)
    @schemas_by_id[id]
  end

  def store_by_id(id, schema)
    @schemas_by_id[id] = schema
  end

  def lookup_by_schema(subject, schema)
    key = [subject, schema.to_s]
    @ids_by_schema[key]
  end

  def store_by_schema(subject, schema, id)
    key = [subject, schema.to_s]
    @ids_by_schema[key] = id
  end

  def lookup_by_version(subject, version)
    key = "#{subject}#{version}"
    @schema_by_subject_version[key]
  end

  def store_by_version(subject, version, schema)
    key = "#{subject}#{version}"
    @schema_by_subject_version[key] = schema
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
avro_turf-1.8.0 lib/avro_turf/in_memory_cache.rb
avro_turf-1.7.0 lib/avro_turf/in_memory_cache.rb
avro_turf-1.6.0 lib/avro_turf/in_memory_cache.rb
avro_turf-1.5.0 lib/avro_turf/in_memory_cache.rb
avro_turf-1.4.1 lib/avro_turf/in_memory_cache.rb
avro_turf-1.4.0 lib/avro_turf/in_memory_cache.rb
avro_turf-1.3.1 lib/avro_turf/in_memory_cache.rb