Cachex v3.1.3 Cachex.Services.Janitor View Source

Expiration service to clean up expired cache records periodically.

The Janitor provides the main expiration cleanup for Cachex, providing a very basic scheduler to repeatedly cleanup cache tables for all expired entries.

This runs in a separate process to avoid any potential overhead in for a user, but uses existing functions in the API so manual cleanup is possible. It’s possible that certain cleanups will result in full table scans, so it should be expected that this can take a while to execute.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor

Pulls an expiration associated with an entry

Determines if a cache entry has expired

Determines if a cache entry has expired

Retrieves information about the latest Janitor run for a cache

Starts a new Janitor process for a cache

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function expiration(arg1, expiration) View Source
expiration(Spec.cache(), integer()) :: integer()

Pulls an expiration associated with an entry.

Link to this function expired?(arg1) View Source
expired?(Spec.entry()) :: boolean()

Determines if a cache entry has expired.

This will not cache lazy expiration settings into account.

Link to this function expired?(arg, entry) View Source
expired?(Spec.cache(), Spec.entry()) :: boolean()

Determines if a cache entry has expired.

This will take cache lazy expiration settings into account.

Link to this function last_run(cache) View Source
last_run(Spec.cache()) :: %{}

Retrieves information about the latest Janitor run for a cache.

If the service is disabled on the cache, an error is returned.

Link to this function start_link(cache) View Source
start_link(Spec.cache()) :: GenServer.on_start()

Starts a new Janitor process for a cache.

At this point customization is non-existent, in order to keep the service as simple as possible and avoid the space for error and edge cases.