View Source ConfluentSchema.Cache (confluent_schema v0.1.3)

Cache Confluent schemas on ETS table.

Link to this section Summary

Functions

Return the cached Confluent schema for a given subject. Raise ArgumentError if cache is not started.

Cache the Confluent schema for a given subject. Raise ArgumentError if cache is not started.

Starts cache for Confluent schemas. Must be called before cache is used. Raise ArgumentError if called more than once.

Link to this section Functions

Link to this function

get(subject, table_name \\ __MODULE__)

View Source

Return the cached Confluent schema for a given subject. Raise ArgumentError if cache is not started.

example

Example

iex> Cache.start()
iex> Cache.set("my-subject", %{"type" => "string"})
iex> Cache.get("my-subject")
{:ok, %{"type" => "string"}}

iex> Cache.start()
iex> Cache.get("my-subject")
{:error, :not_found}
Link to this function

set(subject, schema, table_name \\ __MODULE__)

View Source

Cache the Confluent schema for a given subject. Raise ArgumentError if cache is not started.

example

Example

iex> Cache.start()
iex> Cache.set("my-subject", %{"type" => "string"})
true

iex> assert_raise ArgumentError, fn -> Cache.set("my-subject", %{"type" => "string"}) end
Link to this function

start(table_name \\ __MODULE__)

View Source

Starts cache for Confluent schemas. Must be called before cache is used. Raise ArgumentError if called more than once.

example

Example

iex> Cache.start()
:"Elixir.ConfluentSchema.Cache"

iex> Cache.start()
iex> assert_raise ArgumentError, fn -> Cache.start() end