{"id":13471327,"url":"https://github.com/whatyouhide/redix","last_synced_at":"2025-05-13T00:16:16.412Z","repository":{"id":36266461,"uuid":"40570904","full_name":"whatyouhide/redix","owner":"whatyouhide","description":"Fast, pipelined, resilient Redis driver for Elixir. 🛍","archived":false,"fork":false,"pushed_at":"2025-01-22T08:44:55.000Z","size":881,"stargazers_count":1118,"open_issues_count":3,"forks_count":125,"subscribers_count":17,"default_branch":"main","last_synced_at":"2025-05-13T00:16:09.665Z","etag":null,"topics":["elixir","elixir-library","redis","redis-client","redis-pubsub","redis-sentinel"],"latest_commit_sha":null,"homepage":"http://hexdocs.pm/redix","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/whatyouhide.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"whatyouhide"}},"created_at":"2015-08-11T23:59:17.000Z","updated_at":"2025-05-11T14:26:08.000Z","dependencies_parsed_at":"2023-01-17T00:01:10.855Z","dependency_job_id":"7ef32f5d-04b7-42f4-863c-9aab993a074e","html_url":"https://github.com/whatyouhide/redix","commit_stats":{"total_commits":635,"total_committers":54,"mean_commits":11.75925925925926,"dds":"0.10551181102362206","last_synced_commit":"8e377af6b037a3aac50d3433155d8e940c0a2f83"},"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whatyouhide%2Fredix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whatyouhide%2Fredix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whatyouhide%2Fredix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whatyouhide%2Fredix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whatyouhide","download_url":"https://codeload.github.com/whatyouhide/redix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253843225,"owners_count":21972874,"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-library","redis","redis-client","redis-pubsub","redis-sentinel"],"created_at":"2024-07-31T16:00:43.152Z","updated_at":"2025-05-13T00:16:16.386Z","avatar_url":"https://github.com/whatyouhide.png","language":"Elixir","readme":"# Redix\n\n[![hex.pm badge](https://img.shields.io/badge/Package%20on%20hex.pm-informational)](https://hex.pm/packages/redix)\n[![Documentation badge](https://img.shields.io/badge/Documentation-ff69b4)][docs]\n[![CI](https://github.com/whatyouhide/redix/actions/workflows/main.yml/badge.svg)](https://github.com/whatyouhide/redix/actions/workflows/main.yml)\n[![Coverage Status](https://coveralls.io/repos/github/whatyouhide/redix/badge.svg?branch=main)](https://coveralls.io/github/whatyouhide/redix?branch=main)\n\n\u003e Fast, pipelined, resilient Redis client for Elixir.\n\n![DALL·E Golden Retriever](https://github.com/user-attachments/assets/cd7f8c7a-49ba-46e5-8d35-2b0fa371fdb9)\n\nRedix is a [Redis][redis] and [Valkey][valkey] client written in pure Elixir with focus on speed, correctness, and resiliency (that is, being able to automatically reconnect to Redis in case of network errors).\n\nThis README refers to the main branch of Redix, not the latest released version on Hex. Make sure to check [the documentation][docs] for the version you're using.\n\n## Features\n\n  * Idiomatic interface for sending commands to Redis\n  * Pipelining\n  * Resiliency (automatic reconnections)\n  * Pub/Sub\n  * SSL\n  * Redis Sentinel\n\n## Installation\n\nAdd the `:redix` dependency to your `mix.exs` file. If you plan on connecting to a Redis server [over SSL][docs-ssl] you may want to add the optional [`:castore`][castore] dependency as well:\n\n```elixir\ndefp deps do\n  [\n    {:redix, \"~\u003e 1.1\"},\n    {:castore, \"\u003e= 0.0.0\"}\n  ]\nend\n```\n\nThen, run `mix deps.get` in your shell to fetch the new dependencies.\n\n## Usage\n\nRedix is simple: it doesn't wrap Redis commands with Elixir functions. It only provides functions to send any Redis command to the Redis server. A Redis *command* is expressed as a list of strings making up the command and its arguments.\n\nConnections are started via `start_link/0,1,2`:\n\n```elixir\n{:ok, conn} = Redix.start_link(host: \"example.com\", port: 5000)\n{:ok, conn} = Redix.start_link(\"redis://localhost:6379/3\", name: :redix)\n```\n\nCommands can be sent using `Redix.command/2,3`:\n\n```elixir\nRedix.command(conn, [\"SET\", \"mykey\", \"foo\"])\n#=\u003e {:ok, \"OK\"}\nRedix.command(conn, [\"GET\", \"mykey\"])\n#=\u003e {:ok, \"foo\"}\n```\n\nPipelines are just lists of commands sent all at once to Redis for which Redis replies with a list of responses. They can be used in Redix via `Redix.pipeline/2,3`:\n\n```elixir\nRedix.pipeline(conn, [[\"INCR\", \"foo\"], [\"INCR\", \"foo\"], [\"INCRBY\", \"foo\", \"2\"]])\n#=\u003e {:ok, [1, 2, 4]}\n```\n\n`Redix.command/2,3` and `Redix.pipeline/2,3` always return `{:ok, result}` or `{:error, reason}`. If you want to access the result directly and raise in case there's an error, bang! variants are provided:\n\n```elixir\nRedix.command!(conn, [\"PING\"])\n#=\u003e \"PONG\"\n\nRedix.pipeline!(conn, [[\"SET\", \"mykey\", \"foo\"], [\"GET\", \"mykey\"]])\n#=\u003e [\"OK\", \"foo\"]\n```\n\n#### Resiliency\n\nRedix is resilient against network errors. For example, if the connection to Redis drops, Redix will automatically try to reconnect periodically at a given \"backoff\" interval. Look at the documentation for the `Redix` module and at the [\"Reconnections\" page][docs-reconnections] in the documentation for more information on the available options and on the exact reconnection behaviour.\n\n#### Redis Sentinel\n\nRedix supports [Redis Sentinel][redis-sentinel] out of the box. You can specify a list of sentinels to connect to when starting a `Redix` (or `Redix.PubSub`) connection. Every time that connection will need to connect to a Redis server (the first time or after a disconnection), it will try to connect to one of the sentinels in order to ask that sentinel for the current primary or a replica.\n\n```elixir\nsentinels = [\"redis://sent1.example.com:26379\", \"redis://sent2.example.com:26379\"]\n{:ok, primary} = Redix.start_link(sentinel: [sentinels: sentinels, group: \"main\"])\n```\n\n##### Terminology\n\nRedix doesn't support the use of the terms \"master\" and \"slave\" that are usually used with Redis Sentinel. I don't think those are good terms to use, period. Instead, Redix uses the terms \"primary\" and \"replica\". If you're interested in the discussions around this, [this][redis-terminology-issue] issue in the Redis repository might be interesting to you.\n\n#### Pub/Sub\n\nA `Redix.PubSub` process can be started via `Redix.PubSub.start_link/2`:\n\n```elixir\n{:ok, pubsub} = Redix.PubSub.start_link()\n```\n\nMost communication with the `Redix.PubSub` process happens via Elixir messages (that simulate a Pub/Sub interaction with the pub/sub server).\n\n```elixir\n{:ok, pubsub} = Redix.PubSub.start_link()\n\nRedix.PubSub.subscribe(pubsub, \"my_channel\", self())\n#=\u003e {:ok, ref}\n```\n\nConfirmation of subscriptions is delivered as an Elixir message:\n\n```elixir\nreceive do\n  {:redix_pubsub, ^pubsub, ^ref, :subscribed, %{channel: \"my_channel\"}} -\u003e :ok\nend\n```\n\nIf someone publishes a message on a channel we're subscribed to:\n\n```elixir\nreceive do\n  {:redix_pubsub, ^pubsub, ^ref, :message, %{channel: \"my_channel\", payload: \"hello\"}} -\u003e\n    IO.puts(\"Received a message!\")\nend\n```\n\n## Using Redix in the Real World™\n\nRedix is low-level, but it's still built to handle most things thrown at it. For many applications, you can avoid pooling with little to no impact on performance. Read the [\"Real world usage\" page][docs-real-world-usage] in the documentation for more information on this and pooling strategies that work better with Redix.\n\n## Contributing\n\nTo run the Redix test suite you will have to have Redis running locally. Redix requires a somewhat complex setup for running tests (because it needs a few instances running, for pub/sub and sentinel). For this reason, in this repository you'll find a `docker-compose.yml` file so that you can use [Docker][docker] and [docker compose][docker-compose] to spin up all the necessary Redis instances with just one command. Make sure you have Docker installed and then just run:\n\n```bash\ndocker compose up\n```\n\nNow, you're ready to run tests with the `$ mix test` command.\n\n## License\n\nRedix is released under the MIT license. See the [license file](LICENSE.txt).\n\n[docs]: http://hexdocs.pm/redix\n[redis]: http://redis.io\n[redis-sentinel]: https://redis.io/topics/sentinel\n[castore]: https://github.com/ericmj/castore\n[docs-ssl]: https://hexdocs.pm/redix/Redix.html#module-ssl\n[docs-reconnections]: http://hexdocs.pm/redix/reconnections.html\n[docs-real-world-usage]: http://hexdocs.pm/redix/real-world-usage.html\n[docker]: https://www.docker.com\n[docker-compose]: https://docs.docker.com/compose/\n[redis-terminology-issue]: https://github.com/antirez/redis/issues/5335\n[valkey]: https://valkey.io/\n","funding_links":["https://github.com/sponsors/whatyouhide"],"categories":["Elixir","ORM and Datamapping"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhatyouhide%2Fredix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhatyouhide%2Fredix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhatyouhide%2Fredix/lists"}