org.schemarepo
Interface SchemaEntryCache

All Known Implementing Classes:
InMemorySchemaEntryCache

public interface SchemaEntryCache

A SchemaEntryCache is a bi-directional cache from a schema string to a schema id string. In a given Subject the mapping between a schema and its id is immutable and can be cached. Other aspects of Subject are not safe to cache.

In a Subject schemas are Strings and can not be null or empty. See RepositoryUtil.validateSchemaOrSubject(String)

add(SchemaEntry), lookupById(String), and lookupBySchema(String) must be thread-safe with respect to each-other.


Nested Class Summary
static interface SchemaEntryCache.Factory
          Creates instances of SchemaEntryCache

 
Method Summary
 SchemaEntry add(SchemaEntry entry)
          Add the schema entry to this cache.
 SchemaEntry lookupById(String id)
          Look up a schema entry by its id.
 SchemaEntry lookupBySchema(String schema)
          Look up a schema entry by its full string form.
 

Method Detail

lookupBySchema

SchemaEntry lookupBySchema(String schema)
Look up a schema entry by its full string form. Thread-safe.

Throws:
NullPointerException - If the provided schema is null

lookupById

SchemaEntry lookupById(String id)
Look up a schema entry by its id. Thread-safe.

Throws:
NullPointerException - If the provided id is null

add

SchemaEntry add(SchemaEntry entry)
Add the schema entry to this cache.

Parameters:
entry - schema entry to add. If the provided entry is null, returns null;
Returns:
the SchemaEntry that is in the cache after the call completes. If the entry already exists the pre-existing value is returned, otherwise the value returned is the entry provided. If the provided entry is null, returns null. Thread-safe.


Copyright © 2015. All rights reserved.