View Source Cachex.Services.Janitor (Cachex v3.6.0)

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
@spec expiration(Spec.cache(), integer()) :: integer()

Pulls an expiration associated with an entry.

@spec expired?(Spec.entry()) :: boolean()

Determines if a cache entry has expired.

This will not cache lazy expiration settings into account.

@spec expired?(Spec.cache(), Spec.entry()) :: boolean()

Determines if a cache entry has expired.

This will take cache lazy expiration settings into account.

@spec 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.

@spec 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.