FragmentedKeys.CacheHandler protocol (fragmented_keys v0.1.1)

Copy Markdown View Source

Protocol for cache backend implementations.

Summary

Types

t()

All the types that implement this protocol.

Functions

Fetch a single value by key. Returns nil on miss.

Fetch multiple values at once. Returns map of found key-value pairs.

Return a unique identifier for this handler type.

Store a value, optionally with a TTL in seconds.

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

get(handler, key)

@spec get(t(), String.t()) :: String.t() | nil

Fetch a single value by key. Returns nil on miss.

get_multi(handler, keys)

@spec get_multi(t(), [String.t()]) :: %{required(String.t()) => String.t()}

Fetch multiple values at once. Returns map of found key-value pairs.

group_name(handler)

@spec group_name(t()) :: String.t()

Return a unique identifier for this handler type.

set(handler, key, value, ttl)

@spec set(t(), String.t(), String.t(), non_neg_integer() | nil) :: :ok

Store a value, optionally with a TTL in seconds.