{"id":19124202,"url":"https://github.com/tair-opensource/alibabacloud.tairsdk","last_synced_at":"2025-05-05T19:11:29.421Z","repository":{"id":41328204,"uuid":"504436426","full_name":"tair-opensource/AlibabaCloud.TairSDK","owner":"tair-opensource","description":"Based on StackExchange.Redis that operates Tair For Redis Modules.","archived":false,"fork":false,"pushed_at":"2025-02-28T06:47:12.000Z","size":149,"stargazers_count":11,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-19T11:09:28.766Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","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/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,"zenodo":null}},"created_at":"2022-06-17T07:30:22.000Z","updated_at":"2025-02-28T06:47:16.000Z","dependencies_parsed_at":"2025-04-19T03:42:19.942Z","dependency_job_id":null,"html_url":"https://github.com/tair-opensource/AlibabaCloud.TairSDK","commit_stats":null,"previous_names":["alibaba/alibabacloud.tairsdk"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tair-opensource%2FAlibabaCloud.TairSDK","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tair-opensource%2FAlibabaCloud.TairSDK/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tair-opensource%2FAlibabaCloud.TairSDK/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tair-opensource%2FAlibabaCloud.TairSDK/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tair-opensource","download_url":"https://codeload.github.com/tair-opensource/AlibabaCloud.TairSDK/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252561037,"owners_count":21768063,"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":[],"created_at":"2024-11-09T05:28:24.068Z","updated_at":"2025-05-05T19:11:29.373Z","avatar_url":"https://github.com/tair-opensource.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AlibabaCloud-CSharp-sdk\n\n## 概述\n基于 StackExchange.Redis 封装，用于操作 [云数据库Redis企业版](https://help.aliyun.com/document_detail/145957.html) 的客户端，支持企业版多种 [Module](https://help.aliyun.com/document_detail/146579.html) 的操作命令即部分高级特性。\n\n* [TairString](https://help.aliyun.com/document_detail/145902.html)，支持 string 设置 version，增强`cas`和`cad`命令可轻松实现分布式锁。（已[开源](https://github.com/alibaba/TairString)）\n* [TairHash](https://help.aliyun.com/document_detail/145970.html)，可实现 field 级别的过期。（已[开源](https://github.com/alibaba/TairHash)）\n* [TairZset](https://help.aliyun.com/document_detail/292812.html), 支持多维排序。(已[开源](https://github.com/alibaba/TairZset))\n* [TairDoc](https://help.aliyun.com/document_detail/145940.html), 支持存储`JSON`类型。\n* [TairGis](https://help.aliyun.com/document_detail/145971.html), 支持地理位置点、线、面的相交、包含等关系判断。（已[开源](https://github.com/tair-opensource/TairGis)）\n* [TairBloom](https://help.aliyun.com/document_detail/145972.html), 支持动态扩容的布隆过滤器。\n* [TairRoaring](https://help.aliyun.com/document_detail/311433.html), Roaring Bitmap, 使用少量的存储空间来实现海量数据的查询优化。\n* [TairSearch](https://help.aliyun.com/document_detail/417908.html)，支持 ES-LIKE 语法的全文索引和搜索模块。 \n* [TairCpc](https://help.aliyun.com/document_detail/410587.html), 基于CPC（Compressed Probability Counting）压缩算法开发的数据结构，支持仅占用很小的内存空间对采样数据进行高性能计算。\n* [TairTs](https://help.aliyun.com/document_detail/408954.html), 时序数据结构，提供低时延、高并发的内存读写访问。\n\n## 安装\n本组件是基于 .NET Core 5.0 和 StackExchange.Redis2.5.61 开发，所以用户在使用过程注意安装的 .NET 版本。\n\n该组件已上传至 Nuget，且依赖于 StackExchange.Redis，可直接在Nuget控制界面搜索`AlibabaCloud.TairSDK`以及 `StackExchange.Redis`进行下载安装。\n\n\n## Example\n### 连接\n\n```\nprivate static readonly ConnectionMultiplexer connDC = ConnectionMultiplexer.Connect(\"localhost\");\nprivate readonly TairString tair = new(connDC, 0);\n```\n使用`ConnectionMultiplexer.Connect` 创建一个`ConnectionMultiplexer`实例用来使用。`Connect`可以传入配置字符串或者是`ConfigurationOptions`对象。\n一旦创建了`ConnectionMultiplexer`实例，就可以访问一个`redis`数据库(无论是单机还是集群)。\n\n接下来创建相应`Module`的对象，进而访问数据库。此外`redis`支持多个数据库，所以在`new`一个对象时，通过第二个参数指定对应的数据库。（集群不支持此功能）\n\n### Async\n对于`StackExchange.Redis`，使用\t`ExecuteAsync`返回结果为`Task\u003cRedisResult\u003e`类型，可使用如下方式获取真实结果：\n\n```\nvar ret1 = tairStringAsync.exset(\"key\", \"value\");\nConsole.WriteLine(ResultHelper.Long(ret1.Result));//输出为 \"OK\"\n```\n`.Result`用于得到Async执行完毕的结果，`ResultHelper.Long`用于将`RedisResult`转换为用户需要的结果。\n\n### API使用\nTairString示例如下\n\n```\nusing System.Text;\nusing Alibaba.TairSDK.TairString;\nusing StackExchange.Redis;\n\nnamespace TestString\n{\n    public class Program\n    {\n        private static readonly ConnectionMultiplexer connDC = ConnectionMultiplexer.Connect(\"localhost:6379\");\n        private static readonly TairString tair = new(connDC, 0);\n        \n        static void Main(string[] args)\n        {\n            var bkey = Encoding.UTF8.GetBytes(\"bkey\");\n            var bvalue = Encoding.UTF8.GetBytes(\"bvalue\");\n            var key = \"key\";\n            var value = \"value\";\n\n            //string\n            var ret = tair.exset(key, value);\n            Console.WriteLine(ret);\n            var result = tair.exget(key);\n            Console.WriteLine(result.getValue());\n            Console.WriteLine(result.getVersion());\n            \n\n            //binary\n            ret = tair.exset(bkey, bvalue);\n            Console.WriteLine(ret);\n            var bresult = tair.exget(bkey);\n            Console.WriteLine(Encoding.UTF8.GetString(bresult.getValue()));\n            Console.WriteLine(bresult.getVersion());\n        }\n    } \n\n}\n```\n\n更多示例请参考`Alibaba.TairSDK.Tests`。\n\n## Tair 所有的 SDK\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftair-opensource%2Falibabacloud.tairsdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftair-opensource%2Falibabacloud.tairsdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftair-opensource%2Falibabacloud.tairsdk/lists"}