View Source Flowy.Support.Cache.MemoryStore (Flowy v0.1.1)

A simple in-memory cache store backed by ETS

Options

  • :ttl (integer/0) - the time-to-live for a key in seconds. Default to 5 minutes. The default value is 300.

Summary

Functions

Returns a specification to start this module under a supervisor.

Delete a value from the cache

Fetch a value from the cache, or write the result of the function to the cache if the key does not exist.

Read a value from the cache.

Reset the cache

Write a value to the cache

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

@spec delete(String.t()) :: {:error, :not_found} | {:ok, :deleted}

Delete a value from the cache

Link to this function

fetch(key, fnc, opts \\ [])

View Source
@spec fetch(String.t(), (... -> any()), keyword()) :: {:ok, any()}

Fetch a value from the cache, or write the result of the function to the cache if the key does not exist.

@spec read(
  String.t(),
  keyword()
) :: {:error, :expired | :not_found} | {:ok, any()}

Read a value from the cache.

@spec reset() :: true

Reset the cache

@spec write(String.t(), any()) :: {:ok, any()}

Write a value to the cache