View Source Hammer.ETS (hammer v7.0.0-rc.0)

An ETS backend for Hammer.

To use the ETS backend, you need to start the process that creates and cleans the ETS table. The table is named after the module.

defmodule MyApp.RateLimit do
  use Hammer, backend: :ets
end

MyApp.RateLimit.start_link(clean_period: :timer.minutes(1))

Runtime configuration:

  • :clean_period - (in milliseconds) period to clean up expired entries, defaults to 1 minute

Summary

Functions

Returns a specification to start this module under a supervisor.

Starts the process that creates and cleans the ETS table.

Types

@type start_option() :: {:clean_period, timeout()} | GenServer.option()

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

@spec start_link([start_option()]) :: GenServer.on_start()

Starts the process that creates and cleans the ETS table.

Accepts the following options:

  • :clean_period for how often to perform garbage collection
  • optional :debug, :spawn_opts, and :hibernate_after GenServer options