{"id":18019278,"url":"https://github.com/andytill/oneup","last_synced_at":"2025-03-26T20:31:20.058Z","repository":{"id":34627395,"uuid":"38577061","full_name":"andytill/oneup","owner":"andytill","description":"NIF powered global counters for erlang","archived":false,"fork":false,"pushed_at":"2018-10-07T14:29:54.000Z","size":40,"stargazers_count":24,"open_issues_count":0,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-22T10:25:10.930Z","etag":null,"topics":["atomics","beam","erlang","nif"],"latest_commit_sha":null,"homepage":null,"language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andytill.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":"2015-07-05T17:11:06.000Z","updated_at":"2024-05-04T21:54:31.000Z","dependencies_parsed_at":"2022-09-14T17:20:55.016Z","dependency_job_id":null,"html_url":"https://github.com/andytill/oneup","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andytill%2Foneup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andytill%2Foneup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andytill%2Foneup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andytill%2Foneup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andytill","download_url":"https://codeload.github.com/andytill/oneup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245731392,"owners_count":20663169,"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":["atomics","beam","erlang","nif"],"created_at":"2024-10-30T05:09:41.505Z","updated_at":"2025-03-26T20:31:19.595Z","avatar_url":"https://github.com/andytill.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# oneup\n\nNIF powered, lock-free global counters for erlang using the c++11 atomic package.\n\nOneup is an alternative to `ets:update_counter` with improved throughput for multiple writers without the lock contention that can happen with ets.\n\n### Status\n\noneup is not currently used in production and is subject to API changes. \n\n### Usage\n\nCreate a new counter. This returns a reference that is required for further oneup operations. There is no public registry of oneup counters. Oneup counters are garbage collected like any other erlang primitive e.g. binary or tuple.\n\n```erlang\nC = oneup:new_counter().\n```\n\nIncrement or set the counter. Any number of processes can safely increment or set a counter. A 64 bit signed long is used to hold the value, not an erlang auto number. The maximum value is (2^63-1) or less depending on architecture.\n\n```erlang\nok = oneup:inc(C).              %% value of C becomes 1\nok = oneup:inc2(C, 10).         %% value of C becomes 11\n11 = oneup:set(C, 200).         %% set to 200 and return previous value\n201 = oneup:inc_and_get(C).     %% value of C becomes 201\n401 = oneup:inc_and_get(C,200). %% value of C becomes 401\n```\n\nSet min or max. \n\n```\n300 = oneup:set_max(C, 300). %% set to max of current and new value and return max\n300 = oneup:set_max(C, 100).\n100 = oneup:set_min(C, 100). %% set to min of current and new value and return min\n100 = oneup:set_min(C, 300).\n```\n\nRetrieve the result. Any number of processes can safely read a counter.\n\n```erlang\n200 = oneup:get(C).\n```\n\n### Performance\n\nThe benchnmark suite can be run by executing the following from the oneup directory:\n\n    make perfs\n\nThis runs a benchmarks of oneup and `ets:update_counter` tests. Testing has shown that oneup can achieve upto 100 times the throughput of ets when multiple processes write to a single key.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandytill%2Foneup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandytill%2Foneup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandytill%2Foneup/lists"}