PhoenixKit.Modules.Sitemap.Cache (phoenix_kit v1.7.71)

Copy Markdown View Source

Caching layer for sitemap generation.

Manages ETS cache for entries, per-module XML, and index XML. When invalidated, clears ETS cache and deletes sitemap files.

Cache Key Scheme

  • :index_xml - The sitemapindex XML content
  • {:module_xml, "sitemap-shop"} - Per-module XML content
  • {:module_entries, :shop} - Per-module collected entries
  • :entries - All collected entries (legacy)
  • :parts - Sitemap index parts (legacy)

Summary

Functions

Deletes a specific cache entry.

Retrieves a cached value by key.

Gets cached XML content for a specific module.

Checks if a cached value exists for the given key.

Initializes the ETS cache table.

Clears all cached data and deletes all sitemap files.

Invalidates all cache keys for a specific source module.

Stores a value in cache with the given key.

Caches XML content for a specific module.

Returns cache statistics.

Functions

delete(key)

@spec delete(term()) :: :ok

Deletes a specific cache entry.

get(key)

@spec get(term()) :: {:ok, any()} | :error

Retrieves a cached value by key.

get_module(filename)

@spec get_module(String.t()) :: {:ok, String.t()} | :error

Gets cached XML content for a specific module.

has?(key)

@spec has?(term()) :: boolean()

Checks if a cached value exists for the given key.

init()

@spec init() :: :ok

Initializes the ETS cache table.

Safe to call multiple times - returns :ok if table already exists.

invalidate()

@spec invalidate() :: :ok

Clears all cached data and deletes all sitemap files.

Should be called when sitemap content changes.

invalidate_all()

@spec invalidate_all() :: :ok

Alias for invalidate/0.

invalidate_module(filename)

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

Invalidates all cache keys for a specific source module.

put(key, value)

@spec put(term(), any()) :: :ok

Stores a value in cache with the given key.

put_module(filename, xml)

@spec put_module(String.t(), String.t()) :: :ok

Caches XML content for a specific module.

stats()

@spec stats() :: map()

Returns cache statistics.