-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathconfig_cache.ex
More file actions
35 lines (26 loc) · 1.13 KB
/
config_cache.ex
File metadata and controls
35 lines (26 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
defmodule ConfigCat.ConfigCache do
@moduledoc """
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.
"""
@typedoc "The cache key under which the configuration is stored"
@type key :: String.t()
@typedoc "The result of a cache fetch."
@type result :: {:ok, String.t()} | {:error, :not_found}
@doc """
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 get(key) :: result()
@doc """
Stores an updated serialized configuration under the given cache key.
Returns :ok.
"""
@callback set(key, config :: String.t()) :: :ok | {:error, term()}
end