Storyblok.Cache behaviour (storyblok v2023.12.24-beta.4)

This callback must be implemented to utilize caching.

Implement fetch/2 and set/4 and add the following to your config.

config :storyblok, cache: true, cache_store: MyApp.CacheStore

Summary

Types

Valid JSON

Callbacks

Callback for getting data for key from cache store/

Callback for setting data with the given key. expire_in_ms is the TTL for the key in milliseconds.

Types

@type json() :: binary()

Valid JSON

Callbacks

Link to this callback

fetch(key, opts)

@callback fetch(key :: binary(), opts :: keyword()) ::
  {:ok, json()} | {:error, :not_found}

Callback for getting data for key from cache store/

Link to this callback

set(key, value, expire_in_ms, opts)

@callback set(
  key :: binary(),
  value :: json(),
  expire_in_ms :: integer(),
  opts :: keyword()
) ::
  :ok | {:error, any()}

Callback for setting data with the given key. expire_in_ms is the TTL for the key in milliseconds.