Skip to content

Parsing Method for TsRange() #362

Answered by rueian
b1674927 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @b1674927,

According to the document, you can parse it like this:

package main

import (
	"context"
	"github.com/redis/rueidis"
)

func main() {
	client, err := rueidis.NewClient(rueidis.ClientOption{
		InitAddress: []string{"127.0.0.1:6379"},
	})
	if err != nil {
		panic(err)
	}
	defer client.Close()

	cmd := client.B().TsRange().Key("myTsKey").Fromtimestamp("1693809900000").Totimestamp("1693896300000").Build()
	pairs, err := client.Do(context.Background(), cmd).ToArray()
	if err != nil {
		panic(err)
	}
	for _, pair := range pairs {
		p, _ := pair.ToArray()
		timestamp, _ := p[0].AsInt64()
		value, _ := p[1].ToString()
	}
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by b1674927
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants