{"id":19124206,"url":"https://github.com/tair-opensource/tairzset","last_synced_at":"2025-05-05T19:10:52.266Z","repository":{"id":37019947,"uuid":"421637841","full_name":"tair-opensource/TairZset","owner":"tair-opensource","description":"A redis module, similar to redis zset, but you can set multiple scores for each member to support multi-dimensional sorting","archived":false,"fork":false,"pushed_at":"2023-02-06T02:29:05.000Z","size":347,"stargazers_count":96,"open_issues_count":6,"forks_count":12,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-19T11:09:25.078Z","etag":null,"topics":["module","multiple-scores","redis","zset"],"latest_commit_sha":null,"homepage":"","language":"C","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/tair-opensource.png","metadata":{"files":{"readme":"README-CN.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":"2021-10-27T01:28:38.000Z","updated_at":"2024-12-22T15:32:32.000Z","dependencies_parsed_at":"2024-11-09T05:28:51.423Z","dependency_job_id":"f5e602f1-b55c-4fbf-8fbf-187cc113186f","html_url":"https://github.com/tair-opensource/TairZset","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tair-opensource%2FTairZset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tair-opensource%2FTairZset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tair-opensource%2FTairZset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tair-opensource%2FTairZset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tair-opensource","download_url":"https://codeload.github.com/tair-opensource/TairZset/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252561036,"owners_count":21768062,"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":["module","multiple-scores","redis","zset"],"created_at":"2024-11-09T05:28:24.563Z","updated_at":"2025-05-05T19:10:52.232Z","avatar_url":"https://github.com/tair-opensource.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n![](https://img.shields.io/badge/license-Apache--2.0-green)\n![](https://img.shields.io/badge/PRs-welcome-green)\n[![CMake](https://github.com/alibaba/TairZset/actions/workflows/cmake.yml/badge.svg)](https://github.com/alibaba/TairZset/actions/workflows/cmake.yml)\n[![CI](https://github.com/alibaba/TairZset/actions/workflows/ci.yml/badge.svg)](https://github.com/alibaba/TairZset/actions/workflows/ci.yml)\n[![Docker Image CI](https://github.com/alibaba/TairZset/actions/workflows/docker-image.yml/badge.svg)](https://github.com/alibaba/TairZset/actions/workflows/docker-image.yml)\n\n\n\n\u003cdiv align=center\u003e\n\u003cimg src=\"imgs/tairzset_logo.jpg\" width=\"500\"/\u003e\n\u003c/div\u003e\n   \n\n## 简介  [英文说明](README.md)\n     TairZset是基于redis module开发的一种数据结构，和redis原生的zset数据结构相比，TairZset不但和原生zset一样具有丰富的数据接口和高性能，还提供了（任意）多维排序的能力。\n\n### 主要的特性如下：\n\n- 支持多维(最大255)score排序，且任意维度精度不丢失\n- 在多维score下仍然支持incrby语义\n- 语法和原生zset类似\n\n### 排序规则：      \n对于多维score而言，左边的score优先级大于右边的score，以一个三维score为例：score1#score2#score3，tairzset在比较时，会先比较score1，只有score1相等时才会比较score2，否则就以score1的比较结果作为整个score的比较结果。同理，只有当score2相等时才会比较score3。   \n   \n### 应用场景：\n- 游戏玩家之间排序\n- 直播间主播热度排序\n\n## 快速开始\n```\n127.0.0.1:6379\u003e exzadd tairzsetkey 1.1 x 2.2 y\n(integer) 2\n127.0.0.1:6379\u003e exzrange tairzsetkey 0 -1 withscores\n1) \"x\"\n2) \"1.1000000000000001\"\n3) \"y\"\n4) \"2.2000000000000002\"\n127.0.0.1:6379\u003e exzincrby tairzsetkey 2 x \n\"3.1000000000000001\"\n127.0.0.1:6379\u003e exzrange tairzsetkey 0 -1 withscores\n1) \"y\"\n2) \"2.2000000000000002\"\n3) \"x\"\n4) \"3.1000000000000001\"\n127.0.0.1:6379\u003e exzadd tairzsetkey 3.3#3.3 z\n(error) ERR score is not a valid format\n127.0.0.1:6379\u003e del tairzsetkey\n(integer) 1\n127.0.0.1:6379\u003e exzadd tairzsetkey 1.1#3.3 x 2.2#2.2 y 3.3#1.1 z\n(integer) 3\n127.0.0.1:6379\u003e exzrange tairzsetkey 0 -1 withscores\n1) \"x\"\n2) \"1.1000000000000001#3.2999999999999998\"\n3) \"y\"\n4) \"2.2000000000000002#2.2000000000000002\"\n5) \"z\"\n6) \"3.2999999999999998#1.1000000000000001\"\n127.0.0.1:6379\u003e exzincrby tairzsetkey 2 y \n(error) ERR score is not a valid format\n127.0.0.1:6379\u003e exzincrby tairzsetkey 2#0 y \n\"4.2000000000000002#2.2000000000000002\"\n127.0.0.1:6379\u003e exzrange tairzsetkey 0 -1 withscores\n1) \"x\"\n2) \"1.1000000000000001#3.2999999999999998\"\n3) \"z\"\n4) \"3.2999999999999998#1.1000000000000001\"\n5) \"y\"\n6) \"4.2000000000000002#2.2000000000000002\"\n```\n\n## Docker\n```\ndocker run -p 6379:6379 tairmodule/tairzset:latest\n```\n\n## 编译及使用\n\n```\nmkdir build  \ncd build  \ncmake ../ \u0026\u0026 make -j\n```\n编译成功后会在lib目录下产生tairzset_module.so库文件\n\n```\n./redis-server --loadmodule /path/to/tairzset_module.so\n```\n## 测试方法\n\n1. 修改`tests`目录下tairzset.tcl文件中的路径为`set testmodule [file your_path/tairzset_module.so]`\n2. 将`tests`目录下tairzset.tcl文件路径加入到redis的test_helper.tcl的all_tests中\n3. 在redis根目录下运行./runtest --single tairzset\n\n## 客户端\n\n| language | GitHub |\n|----------|---|\n| Java     |https://github.com/alibaba/alibabacloud-tairjedis-sdk|\n| Python   |https://github.com/alibaba/tair-py|\n| Go       |https://github.com/alibaba/tair-go|\n| .Net     |https://github.com/alibaba/AlibabaCloud.TairSDK|\n\n## API\n[参考这里](CMDDOC.md)\n\n## 适用redis版本\nredis \u003e= 5.0\n\n## 我们的modules\n\n[TairHash](https://github.com/alibaba/TairHash): 和redis hash类似，但是可以为field设置expire和version，支持高效的主动过期和被动过期   \n[TairZset](https://github.com/alibaba/TairZset): 和redis zset类似，但是支持多（最大255）维排序，同时支持incrby语义，非常适合游戏排行榜场景   \n[TairString](https://github.com/alibaba/TairString): 和redis string类似，但是支持设置expire和version，并提供CAS/CAD等实用命令，非常适用于分布式锁等场景  \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftair-opensource%2Ftairzset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftair-opensource%2Ftairzset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftair-opensource%2Ftairzset/lists"}