Skip to content
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.js
go
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 fields

Example ​

go
import "github.com/sahilkhaire/gox/redis"

msg := <-subChan // redis.Message with Channel and Payload fields

Tips ​

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()

← Back to redis package overview

MIT Licensed · Built for Node.js developers moving to Go