tair-go

build workflow Go Reference

English | 简体中文

A client packaged based on go-redis that operates Tair For Redis Modules.

Installation

go get github.com/alibaba/tair-go

Quickstart

An example of TairString is as follows:

go.mod

require (
	github.com/alibaba/tair-go v1.1.0
)

test.go

import (
	"context"
	"fmt"
	"github.com/go-redis/redis/v8"
	"github.com/alibaba/tair-go/tair"
)

var ctx = context.Background()

var tairClient *tair.TairClient

func init() {
	tairClient = tair.NewTairClient(&redis.Options{
		Addr:     "xxx.redis.rds.aliyuncs.com:6379",
		Password: "xxx",
		DB:       0,
	})
}

func main() {
	err := tairClient.ExSet(ctx, "exkey", "exval").Err()
	if err != nil {
		fmt.Println(err.Error())
	}

	val, err := tairClient.ExGet(ctx, "exkey").Result()
	if err != nil {
		panic(err)
	}
	fmt.Println("get exkey values is: ", val)
}

GitHub

View Github