DNS.Zone.Cache (DNS v0.4.1)

View Source

Zone caching system for DNS zones.

Provides in-memory caching for zone data with TTL-based expiration, automatic refresh, and memory management.

Summary

Functions

Clean expired zones from cache.

Clear the entire cache.

Remove a zone from cache.

Get a zone from cache if not expired.

Get cache metadata for a zone.

Initialize the zone cache.

Get all cached zones that are not expired.

Store a zone in cache with TTL.

Refresh a zone from its source if needed.

Get cache statistics.

Check if a zone is cached and not expired.

Functions

cleanup_expired()

@spec cleanup_expired() :: integer()

Clean expired zones from cache.

clear()

@spec clear() :: :ok

Clear the entire cache.

delete_zone(name)

@spec delete_zone(String.t() | DNS.Zone.Name.t()) :: :ok

Remove a zone from cache.

get_zone(name)

@spec get_zone(String.t() | DNS.Zone.Name.t()) ::
  {:ok, DNS.Zone.t()} | {:error, :not_found | :expired}

Get a zone from cache if not expired.

get_zone_meta(name)

@spec get_zone_meta(String.t() | DNS.Zone.Name.t()) ::
  {:ok, map()} | {:error, :not_found}

Get cache metadata for a zone.

init()

@spec init() :: :ok

Initialize the zone cache.

list_zones()

@spec list_zones() :: [{DNS.Zone.t(), map()}]

Get all cached zones that are not expired.

put_zone(zone, ttl_seconds \\ 300, options \\ [])

@spec put_zone(DNS.Zone.t(), integer(), keyword()) :: :ok

Store a zone in cache with TTL.

refresh_zone(name)

@spec refresh_zone(String.t() | DNS.Zone.Name.t()) ::
  {:ok, DNS.Zone.t()} | {:error, String.t()}

Refresh a zone from its source if needed.

stats()

@spec stats() :: map()

Get cache statistics.

zone_cached?(name)

@spec zone_cached?(String.t() | DNS.Zone.Name.t()) :: boolean()

Check if a zone is cached and not expired.