{"id":27573696,"url":"https://github.com/elixir-nebulex/nebulex","last_synced_at":"2026-04-04T12:57:32.819Z","repository":{"id":37493171,"uuid":"81935444","full_name":"elixir-nebulex/nebulex","owner":"elixir-nebulex","description":"In-memory and distributed caching toolkit for Elixir.","archived":false,"fork":false,"pushed_at":"2026-03-27T18:15:12.000Z","size":1340,"stargazers_count":1384,"open_issues_count":5,"forks_count":79,"subscribers_count":10,"default_branch":"main","last_synced_at":"2026-03-28T01:49:29.960Z","etag":null,"topics":["cache","caching","distributed","ecto","elixir","framework"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/nebulex","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/elixir-nebulex.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-02-14T10:48:00.000Z","updated_at":"2026-03-27T18:14:20.000Z","dependencies_parsed_at":"2026-02-07T12:00:48.828Z","dependency_job_id":null,"html_url":"https://github.com/elixir-nebulex/nebulex","commit_stats":{"total_commits":208,"total_committers":27,"mean_commits":7.703703703703703,"dds":"0.14903846153846156","last_synced_commit":"6da0b5407749b0edb0d500fd0c41423e6c2844ef"},"previous_names":["elixir-nebulex/nebulex","cabol/nebulex"],"tags_count":40,"template":false,"template_full_name":null,"purl":"pkg:github/elixir-nebulex/nebulex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-nebulex%2Fnebulex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-nebulex%2Fnebulex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-nebulex%2Fnebulex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-nebulex%2Fnebulex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elixir-nebulex","download_url":"https://codeload.github.com/elixir-nebulex/nebulex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-nebulex%2Fnebulex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31264114,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T02:49:12.781Z","status":"ssl_error","status_checked_at":"2026-04-01T02:49:05.845Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["cache","caching","distributed","ecto","elixir","framework"],"created_at":"2025-04-21T09:02:31.448Z","updated_at":"2026-04-04T12:57:32.797Z","avatar_url":"https://github.com/elixir-nebulex.png","language":"Elixir","funding_links":[],"categories":["Elixir"],"sub_categories":[],"readme":"\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"./guides/images/nbx-logo-white.png\" /\u003e\n  \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"./guides/images/nbx-logo.png\" /\u003e\n  \u003cimg src=\"./guides/images/nbx-logo.png\" alt=\"Nebulex logo\" /\u003e\n\u003c/picture\u003e\n\n\u003e **In-memory and distributed caching toolkit for Elixir**\n\n---\n\n![CI](https://github.com/elixir-nebulex/nebulex/workflows/CI/badge.svg)\n[![Codecov](http://codecov.io/gh/elixir-nebulex/nebulex/graph/badge.svg)](http://codecov.io/gh/elixir-nebulex/nebulex)\n[![Hex.pm](http://img.shields.io/hexpm/v/nebulex.svg)](http://hex.pm/packages/nebulex)\n[![Documentation](http://img.shields.io/badge/Documentation-ff69b4)](https://hexdocs.pm/nebulex)\n\n## 🚀 About\n\nNebulex provides support for transparently adding caching to existing\nElixir applications. Like [Ecto][ecto], the caching abstraction allows\nconsistent use of various caching solutions with minimal impact on your\ncode.\n\nNebulex's cache abstraction shields developers from directly interacting with\nunderlying caching implementations, such as [Redis][redis],\n[Memcached][memcached], or other Elixir cache implementations like\n[Cachex][cachex]. It also provides out-of-the-box features including\n[declarative decorator-based caching][nbx_caching],\n[cache usage patterns][cache_patterns], and\n[distributed cache topologies][cache_topologies],\namong others.\n\n[ecto]: https://github.com/elixir-ecto/ecto\n[cachex]: https://github.com/whitfin/cachex\n[redis]: https://redis.io/\n[memcached]: https://memcached.org/\n[nbx_caching]: https://hexdocs.pm/nebulex/Nebulex.Caching.Decorators.html\n[info_api]: https://hexdocs.pm/nebulex/info-api.html\n[cache_patterns]: https://hexdocs.pm/nebulex/cache-usage-patterns.html\n[cache_topologies]: https://docs.oracle.com/en/middleware/fusion-middleware/coherence/14.1.2/develop-applications/introduction-coherence-caches.html\n\n---\n\n\u003e [!NOTE]\n\u003e\n\u003e This README refers to the main branch of Nebulex, not the latest released\n\u003e version on Hex. Please refer to the [getting started guide][getting_started]\n\u003e and the [official documentation][docs] for the latest stable release.\n\n[getting_started]: https://hexdocs.pm/nebulex/getting-started.html\n[docs]: https://hexdocs.pm/nebulex/Nebulex.html\n\n---\n\n## 📖 Usage\n\nTo use Nebulex, add both `:nebulex` and your chosen cache adapter as\ndependencies in your `mix.exs` file.\n\n\u003e _**For more information about available adapters, check out the\n\u003e [Nebulex adapters][nbx_adapters] guide.**_\n\n[nbx_adapters]: https://hexdocs.pm/nebulex/nbx-adapters.html\n\nFor example, to use the Generational Local Cache\n(`Nebulex.Adapters.Local` adapter), add the following to your `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:nebulex, \"~\u003e 3.0\"},\n    {:nebulex_local, \"~\u003e 3.0\"}, # Generational local cache adapter\n    {:decorator, \"~\u003e 1.4\"},     # Required for caching decorators\n    {:telemetry, \"~\u003e 1.3\"}      # Required for telemetry events\n  ]\nend\n```\n\nTo provide more flexibility and load only the needed dependencies, Nebulex makes\nall dependencies optional, including the adapters. For example:\n\n  * **For enabling [declarative decorator-based caching][nbx_caching]**:\n    Add `:decorator` to the dependency list (recommended).\n\n  * **For enabling Telemetry events**: Add `:telemetry` to the dependency list\n    (recommended). See the [Info API guide][info_api] for monitoring cache stats\n    and metrics.\n\nThen run `mix deps.get` in your shell to fetch the dependencies. If you want to\nuse another cache adapter, just choose the appropriate dependency from the table\nabove.\n\nFinally, in your cache definition, you'll need to specify the `adapter:`\ncorresponding to the chosen dependency. For the local cache, it would be:\n\n```elixir\ndefmodule MyApp.Cache do\n  use Nebulex.Cache,\n    otp_app: :my_app,\n    adapter: Nebulex.Adapters.Local\nend\n```\n\nDon't forget to add `MyApp.Cache` to your application's supervision tree:\n\n```elixir\ndef start(_type, _args) do\n  children = [\n    MyApp.Cache\n  ]\n\n  # ... rest of your supervision tree\n```\n\nYou're now ready to use the cache:\n\n```elixir\niex\u003e MyApp.Cache.put(\"foo\", \"bar\")\n:ok\niex\u003e MyApp.Cache.fetch(\"foo\")\n{:ok, \"bar\"}\n```\n\nFor more detailed information, see the\n[getting started guide][getting_started-rc1] and\n[online documentation][hex-docs].\n\n[getting_started-rc1]: https://hexdocs.pm/nebulex/getting-started.html\n[hex-docs]: https://hexdocs.pm/nebulex/Nebulex.html\n\n---\n\n## ⚡ Quick Start Example with Caching Decorators\n\nThis example demonstrates how to use Nebulex with Ecto and declarative caching:\n\n```elixir\n# In config/config.exs\nconfig :my_app, MyApp.Cache,\n  # Create new generation every 12 hours\n  gc_interval: :timer.hours(12),\n  # Max 1M entries\n  max_size: 1_000_000,\n  # Max 2GB of memory\n  allocated_memory: 2_000_000_000,\n  # Run size and memory checks every 10 seconds\n  gc_memory_check_interval: :timer.seconds(10)\n\n# Cache definition\ndefmodule MyApp.Cache do\n  use Nebulex.Cache,\n    otp_app: :my_app,\n    adapter: Nebulex.Adapters.Local\nend\n\n# Ecto schema\ndefmodule MyApp.Accounts.User do\n  use Ecto.Schema\n\n  schema \"users\" do\n    field :username, :string\n    field :password, :string\n    field :role, :string\n  end\n\n  def changeset(user, attrs) do\n    user\n    |\u003e cast(attrs, [:username, :password, :role])\n    |\u003e validate_required([:username, :password, :role])\n  end\nend\n\n# Accounts context with caching\ndefmodule MyApp.Accounts do\n  use Nebulex.Caching, cache: MyApp.Cache\n\n  alias MyApp.Accounts.User\n  alias MyApp.Repo\n\n  # Cache entries expire after 1 hour\n  @ttl :timer.hours(1)\n\n  @decorate cacheable(key: {User, id}, opts: [ttl: @ttl])\n  def get_user!(id) do\n    Repo.get!(User, id)\n  end\n\n  @decorate cacheable(key: {User, username}, references: \u0026 \u00261.id)\n  def get_user_by_username(username) do\n    Repo.get_by(User, [username: username])\n  end\n\n  @decorate cache_put(\n              key: {User, user.id},\n              match: \u0026__MODULE__.match_update/1,\n              opts: [ttl: @ttl]\n            )\n  def update_user(%User{} = user, attrs) do\n    user\n    |\u003e User.changeset(attrs)\n    |\u003e Repo.update()\n  end\n\n  @decorate cache_evict(key: {User, user.id})\n  def delete_user(%User{} = user) do\n    Repo.delete(user)\n  end\n\n  def create_user(attrs \\\\ %{}) do\n    %User{}\n    |\u003e User.changeset(attrs)\n    |\u003e Repo.insert()\n  end\n\n  def match_update({:ok, value}), do: {true, value}\n  def match_update({:error, _}), do: false\nend\n```\n\n---\n\n## 🔗 Important Links\n\n* [Getting Started][getting_started] - Learn how to set up and use Nebulex.\n* [Documentation][docs] - Complete API reference.\n* [Upgrading to v3.0][upgrading_to_v3] - Migration guide for v3.0.\n* [Declarative caching][declarative_caching] - Declarative Caching: Patterns\n  and Best Practices.\n* [Nebulex Streams][nebulex_streams] - Real-time event streaming for Nebulex\n  caches via `Phoenix.PubSub`.\n* [Examples][examples] - Example applications.\n\n[examples]: https://github.com/elixir-nebulex/nebulex_examples\n[upgrading_to_v3]: https://hexdocs.pm/nebulex/v3-0.html\n[nebulex_streams]: https://github.com/elixir-nebulex/nebulex_streams\n[declarative_caching]: https://hexdocs.pm/nebulex/declarative-caching.html\n\n---\n\n## 🧪 Testing\n\nTo run only the tests:\n\n```bash\n$ mix test\n```\n\nAdditionally, to run all Nebulex checks:\n\n```bash\n$ mix test.ci\n```\n\nThe `mix test.ci` command will run the tests, coverage, credo, dialyzer,\nand more. This is the recommended way to test Nebulex.\n\n---\n\n## 📊 Benchmarks\n\nNebulex provides a set of basic benchmark tests using the library\n[benchee](https://github.com/PragTob/benchee), located in the\n[benchmarks](./benchmarks) directory.\n\nTo run a benchmark test:\n\n```bash\n$ mix bench\n```\n\n\u003e The benchmark uses the `Nebulex.Adapters.Nil` adapter; it is more focused on\n\u003e measuring the Nebulex abstraction layer performance rather than a specific\n\u003e adapter.\n\n---\n\n## 🤝 Contributing\n\nContributions to Nebulex are very welcome and appreciated!\n\nUse the [issue tracker](https://github.com/elixir-nebulex/nebulex/issues)\nfor bug reports or feature requests. Open a\n[pull request](https://github.com/elixir-nebulex/nebulex/pulls)\nwhen you're ready to contribute.\n\nPlease read [CONTRIBUTING.md](CONTRIBUTING.md) for the full contribution\nworkflow, PR expectations, commit message conventions, and validation steps.\n\n---\n\n## 📄 Copyright and License\n\nCopyright (c) 2017, Carlos Bolaños.\n\nNebulex source code is licensed under the [MIT License](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felixir-nebulex%2Fnebulex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felixir-nebulex%2Fnebulex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felixir-nebulex%2Fnebulex/lists"}