View Source Hammer.Backend.EredisCluster (hammer_backend_eredis_cluster v1.0.0)

Documentation for Hammer.Backend.EredisCluster

This backend uses the eredis_cluster library to connect to Redis.

The backend process is started by calling start_link:

Hammer.Backend.EredisCluster.start_link(
  expiry_ms: 60_000 * 10,
  eredis_cluster_name: :mycluster,
  eredis_cluster_init_servers: [
    {"127.0.0.1", 30001},
    {"127.0.0.1", 30002},
    {"127.0.0.1", 30003}
  ],
  eredis_options: [
    username: "myuser",
    password: "mypassword"
  ]
)

Options are:

  • expiry_ms: Expiry time of buckets in milliseconds, used to set TTL on Redis keys. This configuration is mandatory.
  • eredis_cluster_name: The eredis_cluster name to use.
  • eredis_cluster_init_servers: List of tuples of hostname (or IP address) and port number pairs.
  • eredis_options: Keyword list of options that are passed down to eredis.

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

@type bucket_info() ::
  {key :: bucket_key(), count :: integer(), created :: integer(),
   updated :: integer()}
@type bucket_key() :: {bucket :: integer(), id :: String.t()}

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

count_hit(pid, key, now)

View Source

Record a hit in the bucket identified by key

Link to this function

count_hit(pid, key, now, increment)

View Source

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

Link to this function

make_redis_key_pattern(id)

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