{"id":19763061,"url":"https://github.com/exhammer/hammer-backend-mnesia","last_synced_at":"2025-04-30T14:31:35.817Z","repository":{"id":57504119,"uuid":"163022833","full_name":"ExHammer/hammer-backend-mnesia","owner":"ExHammer","description":"Mnesia backend for Hammer","archived":false,"fork":false,"pushed_at":"2024-06-24T03:44:35.000Z","size":62,"stargazers_count":14,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-13T03:19:36.769Z","etag":null,"topics":["elixir","elixir-lang","mnesia","rate-limiter","rate-limiting","throttling"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/hammer-backend-mnesia","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ExHammer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-12-24T20:52:45.000Z","updated_at":"2024-08-13T03:26:17.000Z","dependencies_parsed_at":"2023-01-22T01:57:58.892Z","dependency_job_id":"aeb4c0ac-b02f-41f2-8c9c-7e362315f05c","html_url":"https://github.com/ExHammer/hammer-backend-mnesia","commit_stats":{"total_commits":34,"total_committers":4,"mean_commits":8.5,"dds":"0.20588235294117652","last_synced_commit":"efa2f5420b6ab1fdffd8b4758403b54e94c9195f"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExHammer%2Fhammer-backend-mnesia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExHammer%2Fhammer-backend-mnesia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExHammer%2Fhammer-backend-mnesia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExHammer%2Fhammer-backend-mnesia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ExHammer","download_url":"https://codeload.github.com/ExHammer/hammer-backend-mnesia/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224214101,"owners_count":17274524,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","elixir-lang","mnesia","rate-limiter","rate-limiting","throttling"],"created_at":"2024-11-12T04:07:53.866Z","updated_at":"2025-04-30T14:31:35.776Z","avatar_url":"https://github.com/ExHammer.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hammer.Mnesia\n\n[![Build Status](https://github.com/ExHammer/hammer-backend-mnesia/actions/workflows/ci.yml/badge.svg)](https://github.com/ExHammer/hammer-backend-mnesia/actions/workflows/ci.yml)\n[![Hex.pm](https://img.shields.io/hexpm/v/hammer_backend_mnesia.svg)](https://hex.pm/packages/hammer_backend_mnesia)\n[![Documentation](https://img.shields.io/badge/documentation-gray)](https://hexdocs.pm/hammer_backend_mnesia)\n[![Total Download](https://img.shields.io/hexpm/dt/hammer_backend_mnesia.svg)](https://hex.pm/packages/hammer_backend_mnesia)\n[![License](https://img.shields.io/hexpm/l/hammer_backend_mnesia.svg)](https://github.com/ExHammer/hammer-backend-mnesia/blob/master/LICENSE.md)\n\n\n---\n\n\u003e [!NOTE]\n\u003e\n\u003e This README is for the unreleased master branch, please reference the [official documentation on hexdocs](https://hexdocs.pm/hammer_backend_mnesia/) for the latest stable release.\n\n---\n\nA Mnesia backend for the [Hammer](https://github.com/ExHammer/hammer) rate-limiter.\n\nThis package is available in beta. If you have any problems, please open an issue.\n\n\u003e [!TIP]\n\u003e Consider using `Hammer.ETS` with counter increments broadcasted via [Phoenix PubSub](https://hexdocs.pm/phoenix_pubsub/Phoenix.PubSub.html) instead.\n\n## Installation\n\nThe package can be installed by adding `hammer_backend_mnesia` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:hammer_backend_mnesia, \"~\u003e 0.7.0\"},\n  ]\nend\n```\n\n## Usage\n\n1. Define the rate limiter using `Hammer.Mnesia` backend:\n\n    ```elixir\n    defmodule MyApp.RateLimit do\n      use Hammer, backend: Hammer.Mnesia\n    end\n    ```\n\n2. Add the rate limiter to your supervision tree:\n\n    ```elixir\n    children = [\n      # ...\n      {MyApp.RateLimit, clean_period: :timer.minutes(1)}\n      # ...\n    ]\n    ```\n\n3. And that's it, calls to the rate limiter will use Mnesia to store the counters.\n\n    ```elixir\n    case MyApp.RateLimit.hit(key, _scale = :timer.minutes(1), _limit = 100) do\n      {:allow, _count} -\u003e :ok\n      {:deny, retry_after} -\u003e {:error, :rate_limit, \"retry after #{retry_after}ms\"}\n    end\n    ```\n\n## Documentation\n\nOn hexdocs: [https://hexdocs.pm/hammer_backend_mnesia/](https://hexdocs.pm/hammer_backend_mnesia/)\n\n## Getting Help\n\nIf you're having trouble, either open an issue on this repo, or reach out to the\nmaintainers ([@shanekilkelly](https://twitter.com/shanekilkelly)) on Twitter.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexhammer%2Fhammer-backend-mnesia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexhammer%2Fhammer-backend-mnesia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexhammer%2Fhammer-backend-mnesia/lists"}