Node: ioredisgithub.com/sahilkhaire/gox/redis
Message
Overview
Message is a pub/sub payload.
Part of the redis package — Node.js analog: ioredis.
Message is a type exported by gox. Methods on this type are documented separately.
Signature
go
type Message struct {
Channel string
Payload string
}Compare: Node.js · Standard Go · gox
js
// Typical ioredis pattern in Node.jsgo
rdb := redis.NewClient(&redis.Options{Addr: addr})
val, err := rdb.Get(ctx, key).Result()go
import "github.com/sahilkhaire/gox/redis"
msg := <-subChan // redis.Message with Channel and Payload fieldsExample
go
import "github.com/sahilkhaire/gox/redis"
msg := <-subChan // redis.Message with Channel and Payload fieldsTips
Pass context.Context as the first argument so cancellation and deadlines propagate correctly.
Standard library alternative
Use the standard library directly:
go
rdb := redis.NewClient(&redis.Options{Addr: addr})
val, err := rdb.Get(ctx, key).Result()