View Source Flowy.Support.Cache (Flowy v0.1.0)

The Cache module provides a simple API for interacting with the configured cache store.

Options

Summary

Functions

Builds a cache struct.

Deletes a value from the cache store using the default cache.

Deletes a value from the cache store.

Fetches a value from the cache store. If the key does not exist, the function is called and the result is stored in the cache store.

Reads a value from the cache store using the default cache.

Reads a value from the cache store.

Resets the cache store using the default cache.

Writes a value to the cache store using the default cache.

Writes a value to the cache store.

Types

@type cache() :: t()
@type key() :: String.t() | atom()
@type t() :: %Flowy.Support.Cache{opts: keyword(), store: module()}

Functions

@spec build(opts :: keyword()) :: cache()

Builds a cache struct.

@spec delete(key()) :: {:error, :not_found} | {:ok, :deleted}

Deletes a value from the cache store using the default cache.

@spec delete(cache(), key()) :: {:error, :not_found} | {:ok, :deleted}

Deletes a value from the cache store.

@spec fetch(cache(), key(), function()) :: any()
@spec fetch(key(), function(), opts :: keyword()) :: any()

Fetches a value from the cache store. If the key does not exist, the function is called and the result is stored in the cache store.

@spec read(key()) :: any()

Reads a value from the cache store using the default cache.

@spec read(key(), opts :: keyword()) :: any()
@spec read(cache(), key()) :: any()

Reads a value from the cache store.

@spec reset() :: :ok

Resets the cache store using the default cache.

@spec reset(cache()) :: :ok
@spec write(key(), any()) :: any()

Writes a value to the cache store using the default cache.

Link to this function

write(cache, key, value)

View Source
@spec write(cache(), key(), any()) :: any()

Writes a value to the cache store.