{"id":26563662,"url":"https://github.com/liyiheng/zset","last_synced_at":"2025-03-22T16:16:43.318Z","repository":{"id":41583081,"uuid":"101034375","full_name":"liyiheng/zset","owner":"liyiheng","description":"Sorted set in golang. ","archived":false,"fork":false,"pushed_at":"2024-03-28T02:26:21.000Z","size":38,"stargazers_count":86,"open_issues_count":1,"forks_count":32,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-06-18T23:15:20.015Z","etag":null,"topics":["golang","redis","sorted-set","zset"],"latest_commit_sha":null,"homepage":"","language":"Go","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/liyiheng.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-22T07:27:19.000Z","updated_at":"2024-05-06T14:07:33.000Z","dependencies_parsed_at":"2024-06-18T22:57:35.593Z","dependency_job_id":"8c675158-9b4e-4f66-b04c-873f099bb58b","html_url":"https://github.com/liyiheng/zset","commit_stats":null,"previous_names":["xanthusl/zset"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyiheng%2Fzset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyiheng%2Fzset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyiheng%2Fzset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyiheng%2Fzset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liyiheng","download_url":"https://codeload.github.com/liyiheng/zset/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244982060,"owners_count":20542301,"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":["golang","redis","sorted-set","zset"],"created_at":"2025-03-22T16:16:42.448Z","updated_at":"2025-03-22T16:16:43.283Z","avatar_url":"https://github.com/liyiheng.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/liyiheng/zset)](https://goreportcard.com/report/github.com/liyiheng/zset)\n# zset\nImplementing sorted set in Redis with golang.\n\n## Installation\n```bash\ngo get -u github.com/liyiheng/zset\n```\n\n## Usage\n\n```go\ns := zset.New[int64]()\n// add data\ns.Set(66, 1001)\ns.Set(77, 1002)\ns.Set(88, 1003)\ns.Set(100, 1004)\ns.Set(99, 1005)\ns.Set(44, 1006)\n// update data\ns.Set(44, 1001)\n\n// get rank by key\nrank, score := s.GetRank(1004, false)\n// get data by rank\nid, score := s.GetDataByRank(0, true)\n\ns.Delete(1001)\n\n// Increase score\ns.IncrBy(5.0, 1001)\n\n// ZRANGE, ASC\nfive := make([]int64, 0, 5)\ns.Range(0, 5, func(score float64, k int64) {\n\tfive = append(five, k)\n})\n\n// ZREVRANGE, DESC\nall := make([]int64, 0)\ns.RevRange(0, -1, func(score float64, k int64) {\n\tall = append(all, k)\n})\n\n\n```\n\n## Benchmark\n\n```text\n OS: Arch Linux \n Kernel: x86_64 Linux 5.1.5-arch1-2-ARCH\n CPU: Intel Core i7-8750H @ 12x 4.1GHz [46.0°C]\n RAM: 3295MiB / 7821MiB\n```\n\n```bash\ngo test -test.bench=\".*\"\ngoos: linux\ngoarch: amd64\nBenchmarkSortedSet_Add-12              \t 1000000\t      3050 ns/op\nBenchmarkSortedSet_GetRank-12          \t  500000\t      2963 ns/op\nBenchmarkSortedSet_GetDataByRank-12    \t 2000000\t       620 ns/op\nPASS\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliyiheng%2Fzset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliyiheng%2Fzset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliyiheng%2Fzset/lists"}