Skip to content
Node: ioredisgithub.com/sahilkhaire/gox/redis

Client

Overview

Client wraps go-redis Client.

Part of the redis package — Node.js analog: ioredis.

Client is a type exported by gox. Methods on this type are documented separately.

Signature

go
type Client struct {
	RDB *goredis.Client
}

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"

rdb, err := redis.New("localhost:6379")
if err != nil {
    return err
}
val, err := rdb.Get(ctx, "session:1")

Example

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

rdb, err := redis.New("localhost:6379")
if err != nil {
    return err
}
val, err := rdb.Get(ctx, "session:1")

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