Giter VIP home page Giter VIP logo

hammer-backend-redis's Introduction

HammerBackendRedis

Build Status

Coverage Status

A Redis backend for the Hammer rate-limiter.

Installation

Hammer-backend-redis is available in Hex, the package can be installed by adding hammer_backend_redis to your list of dependencies in mix.exs:

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

Usage

Configure the :hammer application to use the Redis backend:

config :hammer,
  backend: {Hammer.Backend.Redis, [delete_buckets_timeout: 10_0000,
                                   expiry_ms: 60_000 * 60 * 2,
                                   redix_config: [host: "localhost",
                                                  port: 6379]]}

(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.

See the Hammer Tutorial for more.

Documentation

On hexdocs: https://hexdocs.pm/hammer_backend_redis/

Run tests locally

You need a running Redis instance. One can be started locally using docker-compose up -d. Export $HAMMER_REDIS_URL before running the tests. That variable should have the form redis://HOST:PORT (see https://hexdocs.pm/redix/Redix.html#start_link/1-using-a-redis-uri).

Getting Help

If you're having trouble, either open an issue on this repo, or reach out to the maintainers (@shanekilkelly) on Twitter.

hammer-backend-redis's People

Contributors

chaodhib avatar epinault avatar jaimeiniesta avatar kianmeng avatar mpinkston avatar mrnovalles avatar ono avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.