feat: add Pipeline, TxPipeline, Watch and Cluster-safe ScanAll/Del to gredis#4783
Open
ChamHerry wants to merge 1 commit into
Open
feat: add Pipeline, TxPipeline, Watch and Cluster-safe ScanAll/Del to gredis#4783ChamHerry wants to merge 1 commit into
ChamHerry wants to merge 1 commit into
Conversation
… 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 增强)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)Cmdfuture-result type with exportedSetVal/SetErrfor cross-module driver populationPipelinerinterface composingPipelinerOperation(Do/Exec/Discard) +PipelinerGroup(6 typed command group interfaces)Txinterface embeddingPipelinerfor use withWatchAdapterOperationwithPipeline/TxPipeline/WatchmethodsIGroupGenericwithScanAllmethodDriver layer (
contrib/nosql/redis)redisPipelinerimplementation wrapping go-redis (redis.Pipeliner), 99 pipeline group methodscmdEntry+ populate closure pattern: results populated uniformly afterExecScanAll: usesForEachMaster+sync.Mutexto aggregate across all master nodesDel: per-key deletion to avoid CROSSSLOT errorsTest Coverage
Checklist
go build ./...passesgolangci-lint0 issues (1 pre-existing SA4006 inredis_conn.goexcluded)-race_ =discards)