View Source Overview

A Redis backend for the Hammer rate-limiter

Hammer is a rate-limiter for the Elixir language. It's killer feature is a pluggable backend system, allowing you to use whichever storage suits your needs.

This package provides a Redis backend for Hammer, using the Redix library to connect to the Redis server.

To get started, read the Hammer Tutorial first, then add the hammer_backend_redis dependency:

    def deps do
      [{:hammer_backend_redis, "~> 6.1"},
      {:hammer, "~> 6.0"}]
    end

... then configure the :hammer application to use the Redis backend:

config :hammer,
  backend: {Hammer.Backend.Redis, [expiry_ms: 60_000 * 60 * 2,
                                   redix_config: [host: "some.host"]]}

(the redix_config arg is a keyword-list which is passed to Redix, it's also aliased to redis_config, with an s)

And that's it, calls to Hammer.check_rate/3 and so on will use Redis to store the rate-limit counters.