Skip to content

feat: add Pipeline, TxPipeline, Watch and Cluster-safe ScanAll/Del to gredis#4783

Open
ChamHerry wants to merge 1 commit into
gogf:masterfrom
ChamHerry:feat/gredis-pipeline-tx-cluster
Open

feat: add Pipeline, TxPipeline, Watch and Cluster-safe ScanAll/Del to gredis#4783
ChamHerry wants to merge 1 commit into
gogf:masterfrom
ChamHerry:feat/gredis-pipeline-tx-cluster

Conversation

@ChamHerry

Copy link
Copy Markdown

What

Add Pipeline batch execution, TxPipeline transactions, Watch optimistic locking, and Cluster-safe ScanAll/Del operations to the gredis module.

Why

GoFrame Redis previously lacked Pipeline/Transaction batch operations and could not safely perform multi-key deletion or full keyspace scanning in Redis Cluster mode.

How

Abstract layer (database/gredis)

  • New Cmd future-result type with exported SetVal/SetErr for cross-module driver population
  • New Pipeliner interface composing PipelinerOperation (Do/Exec/Discard) + PipelinerGroup (6 typed command group interfaces)
  • New Tx interface embedding Pipeliner for use with Watch
  • Extended AdapterOperation with Pipeline/TxPipeline/Watch methods
  • Extended IGroupGeneric with ScanAll method

Driver layer (contrib/nosql/redis)

  • Full redisPipeliner implementation wrapping go-redis (redis.Pipeliner), 99 pipeline group methods
  • cmdEntry + populate closure pattern: results populated uniformly after Exec
  • Cluster-safe ScanAll: uses ForEachMaster + sync.Mutex to aggregate across all master nodes
  • Cluster-safe Del: per-key deletion to avoid CROSSSLOT errors

Test Coverage

  • 15 abstract layer tests (Cmd lifecycle, nil-receiver safety, interface compliance)
  • 11 driver tests (Pipeline HSet/Get, String ops, multi-group, Discard, DoRaw, TxPipeline, Watch success-path, ScanAll, Del multi-key)

Checklist

  • go build ./... passes
  • golangci-lint 0 issues (1 pre-existing SA4006 in redis_conn.go excluded)
  • All 26 tests pass with -race
  • All exported symbols documented
  • Error handling follows GoFrame conventions (no _ = discards)
  • Import ordering follows gci rules

… gredis

问题描述(What): 为 gredis 抽象层和 go-redis 驱动添加 Pipeline 批量执行、TxPipeline 事务、Watch 乐观锁,以及 Cluster 安全的 ScanAll 和 Del 操作。
根本原因(Why): GoFrame Redis 模块此前不支持 Pipeline/Transaction 批量操作,也无法在 Cluster 模式下安全执行多 key 删除和全量扫描。
修复内容(How): 在抽象层新增 Cmd future-result 类型、Pipeliner 接口体系(6 个命令组 + Tx)、在 AdapterOperation 扩展 Pipeline/TxPipeline/Watch 方法;在驱动层完整实现 99 个 pipeline 组方法,并增加 Cluster 感知的 ScanAll(ForEachMaster 遍历)和逐 key Del(规避 CROSSSLOT)。
技术细节(Details): Cmd 使用导出的 SetVal/SetErr 供驱动跨模块填充结果;redisPipeliner 通过 cmdEntry + populate 闭包在 Exec 后统一填充;ScanAll 在 Cluster 模式下使用 ForEachMaster + sync.Mutex 聚合结果;Del 在 Cluster 模式下逐 key 删除并收集首个错误。
影响范围(Impact): database/gredis(抽象层接口+Cmd 类型)、contrib/nosql/redis(驱动实现+Cluster 增强)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant