{"id":25930977,"url":"https://github.com/sean-lin/globalconst","last_synced_at":"2026-05-22T16:37:35.130Z","repository":{"id":62429840,"uuid":"156415375","full_name":"sean-lin/globalconst","owner":"sean-lin","description":"GlobalConst converts large Key-Value entities to a module to make fast accessing by thousands of processes.","archived":false,"fork":false,"pushed_at":"2020-04-26T17:59:22.000Z","size":13,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-23T23:11:17.102Z","etag":null,"topics":["elixir"],"latest_commit_sha":null,"homepage":null,"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/sean-lin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-06T16:41:46.000Z","updated_at":"2020-04-26T17:59:24.000Z","dependencies_parsed_at":"2022-11-01T20:09:40.992Z","dependency_job_id":null,"html_url":"https://github.com/sean-lin/globalconst","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sean-lin/globalconst","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sean-lin%2Fglobalconst","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sean-lin%2Fglobalconst/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sean-lin%2Fglobalconst/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sean-lin%2Fglobalconst/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sean-lin","download_url":"https://codeload.github.com/sean-lin/globalconst/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sean-lin%2Fglobalconst/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33354040,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-21T12:23:38.849Z","status":"online","status_checked_at":"2026-05-22T02:00:06.671Z","response_time":265,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["elixir"],"created_at":"2025-03-03T23:56:20.826Z","updated_at":"2026-05-22T16:37:35.114Z","avatar_url":"https://github.com/sean-lin.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GlobalConst\n\n[![Hex.pm Version](https://img.shields.io/hexpm/v/globalconst.svg?style=flat)](https://hex.pm/packages/globalconst)\n\nGlobalConst converts large Key-Value entities to a module to make fast accessing by thousands of processes.\n\n## Thanks\n\nThis library inspired by [FastGlobal](https://github.com/discordapp/fastglobal) and [mochiglobal](https://github.com/mochi/mochiweb/blob/master/src/mochiglobal.erl). \nIn our case, we has thousands of entities to save, and don't want to make so many modules. \nSo converting entities to a named module is a good approach. \n\n## Performance\nRun `mix test`\n\n```\n## GlobalConstBench\nbenchmark name                     iterations   average time\nglobalconst get string              100000000   0.04 µs/op\nglobalconst get atom                100000000   0.04 µs/op\nglobalconst get(10000keys) atom     100000000   0.06 µs/op\nglobalconst get(10000keys) string   100000000   0.07 µs/op\nets get atom                         10000000   0.24 µs/op\nets get string                       10000000   0.28 µs/op\nfastglobal get                       10000000   0.36 µs/op\nagent get                              100000   19.62 µs/op\n```\n\n## Installation\n\nAdd it to `mix.exs`\n\n```elixir\ndef deps do\n  [\n    {:globalconst, \"~\u003e 0.3.0\"}\n  ]\nend\n```\n\nDocumentation can be found at [https://hexdocs.pm/globalconst/](https://hexdocs.pm/globalconst/).\n\n## Usage\n\nCreate a new global const map and get the value\n\n```elixir\nGlobalConst.new(GlobalMap, %{a: 1, b: 2})  # GlobalConst.new(GlobalMap, %{a: 1, b: 2}, [key_type: :atom])\n1 == GlobalMap.get(:a)\n2 == GlobalMap.get(:b)\n[:a, :b] == GlobalMap.keys()\n{:error, :global_const_not_found} = GlobalMap.get(:c)\n:default_value = GlobalMap.get(:c, :default_value)\n\nGlobalConst.new(GlobalMapAny, %{:a =\u003e 1, \"b\" =\u003e 2, 3 =\u003e 3, [:c] =\u003e 4}, [key_type: :any])\n1 == GlobalMapAny.get(:a)\n2 == GlobalMapAny.get(\"b\")\n3 == GlobalMapAny.get(3)\n4 == GlobalMapAny.get([:c])\n\n```\n\nDefine a DummyModule to stop compiler warning.\n```elixir\ndefmodule GlobalMap do\n  use GlobalConst.DummyModule\nend\nGlobalConst.new(GlobalMap, %{a: 1, b: 2}) \n\n1 == GlobalMap.get(:a)  # no compiler warning here.\n```\n\n## License\n\nGlobalConst is released under [the MIT License](LICENSE).\nCheck [LICENSE](LICENSE) file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsean-lin%2Fglobalconst","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsean-lin%2Fglobalconst","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsean-lin%2Fglobalconst/lists"}