View Source ConfigCat.ConfigCache behaviour (ConfigCat v4.0.1)

Defines a configuration cache.

A calling application can optionally supply its own cache implementation to use in place of the default in-memory cache by providing the implementation's module name as the :cache option in ConfigCat.child_spec/1.

The provided implementation must explicitly or implicitly implement this behaviour.

If the cache implementation is a GenServer or similar, it is the calling application's responsibility to add it to its own supervision tree.

Summary

Types

The cache key under which the configuration is stored

The result of a cache fetch.

Callbacks

Fetches the serialized configuration stored under the given cache key.

Stores an updated serialized configuration under the given cache key.

Types

@type key() :: String.t()

The cache key under which the configuration is stored

@type result() :: {:ok, String.t()} | {:error, :not_found}

The result of a cache fetch.

Callbacks

@callback get(key()) :: result()

Fetches the serialized configuration stored under the given cache key.

Returns {:ok, serialized_config} if there is a cached configuration or {:error, :not_found} if not.

@callback set(key(), config :: String.t()) :: :ok | {:error, term()}

Stores an updated serialized configuration under the given cache key.

Returns :ok.