Skip to content

Commit

Permalink
feat: add PubSub to rueidiscompat (#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
rueian authored Jul 27, 2024
1 parent 2d299e6 commit fc024ae
Show file tree
Hide file tree
Showing 3 changed files with 972 additions and 0 deletions.
22 changes: 22 additions & 0 deletions rueidiscompat/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ type ProbabilisticCmdable interface {
TDigestReset(ctx context.Context, key string) *StatusCmd
TDigestRevRank(ctx context.Context, key string, values ...float64) *IntSliceCmd
TDigestTrimmedMean(ctx context.Context, key string, lowCutQuantile, highCutQuantile float64) *FloatCmd

Subscribe(ctx context.Context, channels ...string) PubSub
PSubscribe(ctx context.Context, patterns ...string) PubSub
SSubscribe(ctx context.Context, channels ...string) PubSub
}

// Align with go-redis
Expand Down Expand Up @@ -4596,6 +4600,24 @@ func (c *Compat) JSONType(ctx context.Context, key, path string) *JSONSliceCmd {
return newJSONSliceCmd(c.client.Do(ctx, cmd))
}

func (c *Compat) Subscribe(ctx context.Context, channels ...string) PubSub {
p := newPubSub(c.client)
_ = p.Subscribe(ctx, channels...)
return p
}

func (c *Compat) SSubscribe(ctx context.Context, channels ...string) PubSub {
p := newPubSub(c.client)
_ = p.SSubscribe(ctx, channels...)
return p
}

func (c *Compat) PSubscribe(ctx context.Context, patterns ...string) PubSub {
p := newPubSub(c.client)
_ = p.PSubscribe(ctx, patterns...)
return p
}

func (c CacheCompat) BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd {
var resp rueidis.RedisResult
if bitCount == nil {
Expand Down
Loading

0 comments on commit fc024ae

Please sign in to comment.