Electric.Client.ExpiredShapesCache (Electric Client v0.10.2)

Copy Markdown View Source

LRU cache for tracking expired shape handles.

This cache stores shape handles that have been marked as expired (typically after receiving a 409 response). When making subsequent requests for the same shape, the client includes the expired handle as a query parameter to help bypass stale CDN/proxy caches.

The cache uses ETS for fast concurrent reads and a GenServer to manage LRU eviction when the cache exceeds the maximum number of entries.

Summary

Functions

Returns a specification to start this module under a supervisor.

Clear all entries from the cache.

Clear the expired handle for a single shape key.

Get the expired handle for a shape key, if one exists.

Mark a shape handle as expired for the given shape key.

Get the current number of entries in the cache.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear()

@spec clear() :: :ok

Clear all entries from the cache.

clear_handle(shape_key)

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

Clear the expired handle for a single shape key.

get_expired_handle(shape_key)

@spec get_expired_handle(String.t()) :: String.t() | nil

Get the expired handle for a shape key, if one exists.

Updates the last_used timestamp to maintain LRU ordering.

mark_expired(shape_key, handle)

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

Mark a shape handle as expired for the given shape key.

If the cache exceeds the maximum number of entries, the least recently used entry will be evicted.

size()

@spec size() :: non_neg_integer()

Get the current number of entries in the cache.

Primarily for testing purposes.

start_link(opts \\ [])