{"id":48805545,"url":"https://github.com/tsmask/redka","last_synced_at":"2026-04-14T05:00:57.902Z","repository":{"id":350367579,"uuid":"1195956605","full_name":"TsMask/redka","owner":"TsMask","description":"Redis用SQL重新实现，与Redis API保持兼容","archived":false,"fork":false,"pushed_at":"2026-04-10T02:10:02.000Z","size":151,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-10T04:12:03.221Z","etag":null,"topics":["key-value","mysql","postgres","rdb-proxy","redis-server","sqlite"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TsMask.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-30T08:23:56.000Z","updated_at":"2026-04-10T02:10:09.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/TsMask/redka","commit_stats":null,"previous_names":["tsmask/redka"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/TsMask/redka","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TsMask%2Fredka","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TsMask%2Fredka/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TsMask%2Fredka/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TsMask%2Fredka/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TsMask","download_url":"https://codeload.github.com/TsMask/redka/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TsMask%2Fredka/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31782740,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T02:24:21.117Z","status":"ssl_error","status_checked_at":"2026-04-14T02:24:20.627Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["key-value","mysql","postgres","rdb-proxy","redis-server","sqlite"],"created_at":"2026-04-14T05:00:57.246Z","updated_at":"2026-04-14T05:00:57.893Z","avatar_url":"https://github.com/TsMask.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Redka\n\n\u003cimg alt=\"Redka\" src=\"logo.svg\" height=\"80\" align=\"center\"\u003e\n\n\u003e 本项目基于 [fork nalgeon/redka](https://github.com/nalgeon/redka) 二次开发\n\nRedka 是一个用 Go 语言实现的 Redis 兼容服务器，使用关系型数据库作为后端存储，同时保持与 Redis API 的完全兼容。\n\n## 特性\n\n- **多后端支持**: 支持 SQLite、PostgreSQL、MySQL 作为后端存储\n- **内存高效**: 数据无需全部加载到内存，支持持久化存储\n- **ACID 事务**: 提供完整的事务支持，确保数据一致性\n- **SQL 视图**: 提供 SQL 视图便于数据分析和报表生成\n- **灵活部署**: 可嵌入 Go 应用使用，或作为独立服务器运行\n- **Redis 兼容**: 完整实现 Redis 命令和 RESP 通信协议\n- **认证支持**: 支持密码认证，保障服务安全\n- **配置管理**: 支持 YAML 配置文件和命令行参数\n- **日志系统**: 提供结构化日志，支持文件输出和详细日志模式\n- **Unix Socket**: 支持 Unix Domain Socket 连接\n\n## 支持的数据类型\n\nRedka 支持 Redis 五种核心数据类型：\n\n- **字符串 (String)** - 最基础的 Redis 类型，表示字节序列\n- **列表 (List)** - 按插入顺序排序的字符串序列\n- **集合 (Set)** - 无序且唯一的字符串集合\n- **哈希 (Hash)** - 键值对映射\n- **有序集合 (Sorted Set)** - 按关联分数排序的唯一字符串集合\n\nRedka 还提供键管理、服务器/连接管理命令。\n\n## 配置\n\nRedka 支持命令行参数和 YAML 配置文件。\n\n```bash\n# 使用内存数据库启动（默认端口 6379）\n./redka\n\n# 使用配置文件启动\n./redka -c config.example.yaml\n\n# 使用文件数据库启动\n./redka -p 6380 redka.db\n\n# 使用 Unix Socket\n./redka -s /tmp/redka.sock redka.db\n```\n\n### 命令行参数\n\n```bash\n./redka [-h host] [-p port] [-s unix-socket] [-a password] [-c config-file] [-v] [db-dsn]\n```\n\n| 参数 | 说明 | 默认值 |\n|------|------|--------|\n| `-h` | 监听地址 | `0.0.0.0` |\n| `-p` | 监听端口 | `6379` |\n| `-s` | Unix socket 路径（覆盖 host 和 port） | 无 |\n| `-a` | 认证密码 | 无 |\n| `-c` | 配置文件路径（会被命令行参数覆盖） | 无 [配置文件示例](./scripts/redka.yaml) |\n| `-v` | 启用详细日志和性能分析端点 | `false` |\n| `db-dsn` | 数据库连接字符串 | `file:/tmp/redka.sqlite?vfs=memdb` |\n\n### DSN 格式说明\n\n| 数据库类型 | DSN 示例 |\n|------------|----------|\n| SQLite | `file:redka.db` 或 `sqlite:/path/to/db` 或直接文件路径 |\n| PostgreSQL | `postgres://user:password@localhost:5432/dbname` |\n| MySQL | `mysql://user:password@tcp(localhost:3306)/dbname` |\n\n## 数据库后端\n\nRedka 使用 GORM 作为 ORM，支持三种关系型数据库后端：\n\n- **SQLite**: 轻量级，进程内存储，适合开发和测试\n- **PostgreSQL**: 功能强大的开源数据库，适合生产环境\n- **MySQL**: 广泛使用的关系型数据库，支持 MariaDB\n\n## 性能\n\nRedka 不追求极致性能。使用 SQLite 这种通用关系型后端无法击败 Redis 这种专用数据存储。但 Redka 仍能处理每秒数万次操作，对许多应用来说足够了。\n\n## 技术栈\n\n- **语言**: Go 1.25+\n- **协议**: RESP (Redis Serialization Protocol)\n- **网络**: 基于 [Redcon](https://github.com/tidwall/redcon) 库实现\n- **ORM**: [GORM](https://gorm.io/)\n- **数据库驱动**: SQLite3, PostgreSQL, MySQL\n\n## 项目结构\n\n```text\nredka/\n├── main.go                # 服务入口\n├── server/                # 服务器实现\n├── internal/              # 内部核心模块\n│   ├── core/              # 核心类型定义\n│   ├── store/             # 数据库存储层\n│   ├── rstring/          # 字符串操作\n│   ├── rlist/             # 列表操作\n│   ├── rset/              # 集合操作\n│   ├── rzset/             # 有序集合操作\n│   └── rhash/             # 哈希操作\n├── config/                # 配置管理\n├── scripts/               # 脚本和配置示例\n└── README.md              # 本文件\n```\n\n## 测试\n\n```bash\n# 运行功能测试脚本（需先启动服务）\n./test-redis-cli.sh [port] [host] [password]\n\n# 示例\n./test-redis-cli.sh 6380 127.0.0.1 password\n```\n\n测试脚本会自动检测 command.go 中支持的全部命令，确保测试覆盖完整。\n\n## 打包\n\n```bash\n# 打包 Deb 包\n./scripts/build-deb.sh\n\n# 打包 RPM 包\n./scripts/build-rpm.sh\n\n# 普通二进制\nmake build\n```\n\n## 贡献\n\n欢迎贡献代码，请先开 issue 讨论你想做的更改。\n\n欢迎使用AI工具诊断该项目，并添加或更新功能测试。\n\n## 致谢\n\nRedka 的实现离不开这些优秀项目及其创建者：\n\n- [Redis](https://redis.io/) ([Salvatore Sanfilippo](https://github.com/antirez)) - 提供超越 get-set 范式的数据结构便捷 API\n- [SQLite](https://sqlite.org/) ([D. Richard Hipp](https://www.sqlite.org/crew.html)) - 驱动世界的进程内数据库\n- [Redcon](https://github.com/tidwall/redcon) ([Josh Baker](https://github.com/tidwall)) - 简洁易用的 RESP 服务器实现\n- [GORM](https://gorm.io/) - Go 语言的 ORM 库\n- [Fork nalgeon/redka](https://github.com/nalgeon/redka) - Redka用SQL重新实现，与Redis API保持兼容\n\nLogo 字体由 [Ek Type](https://ektype.in/) 提供。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsmask%2Fredka","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsmask%2Fredka","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsmask%2Fredka/lists"}