hammer_backend_redis v1.0.0 Hammer.Backend.Redis View Source

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
  • redix_config: Keyword list of options to the Redix redis client, also aliased to redis_config

Link to this section Summary

Functions

Record a hit in the bucket identified by key

Delete all buckets associated with id

Retrieve information about the bucket identified by key

Link to this section Functions

Link to this function count_hit(key, now) View Source
count_hit(key :: {bucket :: integer, id :: String.t}, now :: integer) ::
  {:ok, count :: integer} |
  {:error, reason :: String.t}

Record a hit in the bucket identified by key

Link to this function delete_buckets(id) View Source
delete_buckets(id :: String.t) ::
  {:ok, count_deleted :: integer} |
  {:error, reason :: String.t}

Delete all buckets associated with id.

Link to this function get_bucket(key) View Source
get_bucket(key :: {bucket :: integer, id :: String.t}) ::
  {:ok, {key :: {bucket :: integer, id :: String.t}, count :: integer, created :: integer, updated :: integer}} |
  {:ok, nil} |
  {:error, reason :: any}

Retrieve information about the bucket identified by key