View Source Chord.Cleanup (Chord v0.1.4)

This module provides functionality to clean up data that is no longer needed, such as old contexts or deltas, ensuring efficient use of storage and memory.

Key Features

  • Time-Based Cleanup: Periodically remove stale contexts or deltas based on configurable time-to-live (TTL) values.
  • Threshold-Based Cleanup: Retain only the latest N deltas per context, defined by the :delta_threshold configuration.
  • Periodic Cleanup: A convenient API for batch cleanup of multiple contexts and deltas.

Configuration

  • :context_auto_delete (default: false): Whether to enable automatic context deletion during cleanup.
  • :context_ttl (default: nil): Time-to-live for context entries.
  • :delta_ttl (default: 24 hours): Time-to-live for deltas.
  • :delta_threshold (default: 100): Maximum number of deltas to retain per context.
  • :backend: The backend module used for context and delta storage (default: Chord.Backend.ETS).

Example Usage

iex> Chord.Cleanup.periodic_cleanup(limit: 10)
:ok

Summary

Functions

Performs periodic cleanup for contexts and deltas.

Functions

periodic_cleanup(opts \\ [])

@spec periodic_cleanup(keyword()) :: :ok

Performs periodic cleanup for contexts and deltas.

This function fetches all contexts and deltas from the backend, checks their times against the configured TTL values, and removes stale entries.

Parameters

  • opts (Keyword.t): Optional parameters for fetching contexts and deltas (see "Common Options" in the Chord module).

Returns

  • :ok after performing the cleanup.

Example

iex> Chord.Cleanup.periodic_cleanup(limit: 10)
:ok