View Source ConfluentSchema.Cache (confluent_schema v0.1.0)

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

@spec get(binary()) :: {:ok, map()} | {:error, :not_found} | no_return()

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}
@spec set(binary(), map()) :: true | no_return()

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
@spec start() :: true | no_return()

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

example

Example

iex> Cache.start()
:confluent_schema_cache

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