ExGitEngine.Cache behaviour (ex_git_engine v0.9.0)

Copy Markdown

Behaviour for caching Git operations.

Summary

Callbacks

Fetches the value for a specific cache_key.

Initialize the cache for the given path.

Returns the cache key for the given op or nil if the operation should not be cached.

Puts the given cache_entry under cache_key.

Types

cache()

@type cache() :: term()

cache_entry()

@type cache_entry() :: term()

cache_key()

@type cache_key() :: term()

op()

@type op() :: atom() | tuple()

Callbacks

fetch_cache(cache, cache_key)

@callback fetch_cache(cache(), cache_key()) :: cache_entry() | nil

Fetches the value for a specific cache_key.

init_cache(path, opts)

@callback init_cache(path :: Path.t(), opts :: keyword()) :: cache()

Initialize the cache for the given path.

make_cache_key(op)

@callback make_cache_key(op()) :: cache_key() | nil

Returns the cache key for the given op or nil if the operation should not be cached.

put_cache(cache, cache_key, cache_entry)

@callback put_cache(cache(), cache_key(), cache_entry()) :: :ok

Puts the given cache_entry under cache_key.