Volt.Cache (Volt v0.10.1)

Copy Markdown View Source

ETS-backed module cache keyed by {path, mtime}.

Caches compiled output so repeated requests for unchanged files skip the compilation step entirely.

Summary

Functions

Clear all cached entries.

Create the cache ETS table. Called once from Application.start/2.

Evict all entries for a path (any mtime).

Look up a cached entry. Returns nil on miss.

Store a compiled entry.

Types

entry()

@type entry() :: %{
  code: String.t(),
  sourcemap: String.t() | nil,
  css: String.t() | nil,
  hashes:
    %{
      template: String.t() | nil,
      style: String.t() | nil,
      script: String.t() | nil
    }
    | nil,
  content_type: String.t()
}

Functions

clear()

@spec clear() :: :ok

Clear all cached entries.

create_table()

@spec create_table() :: :ok

Create the cache ETS table. Called once from Application.start/2.

evict(path)

@spec evict(String.t()) :: :ok

Evict all entries for a path (any mtime).

get(path, mtime)

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

Look up a cached entry. Returns nil on miss.

put(path, mtime, entry)

@spec put(String.t(), integer(), entry()) :: :ok

Store a compiled entry.