View Source Hammer.Backend.Redis (hammer_backend_redis v6.2.0)

Documentation for Hammer.Backend.Redis

This backend uses the Redix library to connect to Redis.

The backend process is started by calling start_link:

Hammer.Backend.Redis.start_link(
  expiry_ms: 60_000 * 10,
  redix_config: [host: "example.com", port: 5050]
)

Options are:

  • expiry_ms: Expiry time of buckets in milliseconds, used to set TTL on Redis keys. This configuration is mandatory.
  • redix_config: Keyword list of options to the Redix redis client, also aliased to redis_config
  • key_prefix: The prefix to use for all the redis keys (defaults to "Hammer:Redis:")
  • redis_url: String url of redis server to connect to (optional, invokes Redix.start_link/2)

Summary

Functions

Returns a specification to start this module under a supervisor.

Record a hit in the bucket identified by key

Record a hit in the bucket identified by key, with a custom increment

Delete all buckets associated with id.

Retrieve information about the bucket identified by key

Types

bucket_info()

@type bucket_info() ::
  {key :: bucket_key(), count :: integer(), created :: integer(),
   updated :: integer()}

bucket_key()

@type bucket_key() :: {bucket :: integer(), id :: String.t()}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

count_hit(pid, key, now)

Record a hit in the bucket identified by key

count_hit(pid, key, now, increment)

Record a hit in the bucket identified by key, with a custom increment

delete_buckets(pid, id)

Delete all buckets associated with id.

get_bucket(pid, key)

Retrieve information about the bucket identified by key

start()

@spec start() :: :ignore | {:error, any()} | {:ok, pid()}

start(args)

@spec start(keyword()) :: :ignore | {:error, any()} | {:ok, pid()}

start_link()

@spec start_link() :: :ignore | {:error, any()} | {:ok, pid()}

start_link(args)

@spec start_link(keyword()) :: :ignore | {:error, any()} | {:ok, pid()}

stop()

@spec stop() :: any()