func ExampleClient_MultiReverseRangeWithOptions() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client-1")
	client.FlushAll()
	labels1 := map[string]string{
		"machine": "machine-1",
		"az":      "us-east-1",
	}
	client.AddWithOptions("time-serie-1", 2, 1.0, redistimeseries.CreateOptions{Labels: labels1})
	client.Add("time-serie-1", 4, 2.0)
	labels2 := map[string]string{
		"machine": "machine-2",
		"az":      "us-east-1",
	}
	client.AddWithOptions("time-serie-2", 1, 5.0, redistimeseries.CreateOptions{Labels: labels2})
	client.Add("time-serie-2", 4, 10.0)
	ranges, _ := client.MultiReverseRangeWithOptions(1, 10, redistimeseries.DefaultMultiRangeOptions, "az=us-east-1")
	fmt.Printf("Ranges: %v\n", ranges)
}
Exemplifies the usage of MultiReverseRangeWithOptions function.
nolint:errcheck
package redis_timeseries_go_test
import (
	"fmt"
	redistimeseries "github.com/RedisTimeSeries/redistimeseries-go"
	"github.com/gomodule/redigo/redis"
	"log"
	"time"
)
func ExampleNewClientFromPool() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client-1")
	client.Add("ts", 1, 5)
	datapoints, _ := client.RangeWithOptions("ts", 0, 1000, redistimeseries.DefaultRangeOptions)
	fmt.Println(datapoints[0])
}
func ExampleClient_CreateKeyWithOptions() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client-1")
	client.CreateKeyWithOptions("time-serie-last-policy", redistimeseries.CreateOptions{DuplicatePolicy: redistimeseries.LastDuplicatePolicy})
	client.Add("time-serie-last-policy", 4, 2.0)
	client.Add("time-serie-last-policy", 4, 10.0)
	latestDatapoint, _ := client.Get("time-serie-last-policy")
	fmt.Printf("Latest datapoint: timestamp=%d value=%f\n", latestDatapoint.Timestamp, latestDatapoint.Value)
}
func ExampleClient_CreateKeyWithOptions_retentionTime() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client")
	options := redistimeseries.DefaultCreateOptions
	options.RetentionMSecs = time.Hour
	client.CreateKeyWithOptions("time-series-example-retention-time", options)
	client.Add("time-series-example-retention-time", 1, 1)
	client.Add("time-series-example-retention-time", 2, 2)
	latestDatapoint, _ := client.Get("time-series-example-retention-time")
	fmt.Printf("Latest datapoint: timestamp=%d value=%f\n", latestDatapoint.Timestamp, latestDatapoint.Value)
}
func ExampleClient_Add() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client-1")
	labels := map[string]string{
		"machine": "machine-1",
		"az":      "us-west-2",
	}
	options := redistimeseries.DefaultCreateOptions
	options.Labels = labels
	client.CreateKeyWithOptions("time-serie-add", options)
	client.Add("time-serie-add", 1, 2.0)
	client.Add("time-serie-add", 2, 4.0)
	latestDatapoint, _ := client.Get("time-serie-add")
	fmt.Printf("Latest datapoint: timestamp=%d value=%f\n", latestDatapoint.Timestamp, latestDatapoint.Value)
}
func ExampleClient_Add_backFilling() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client-1")
	options := redistimeseries.DefaultCreateOptions
	client.CreateKeyWithOptions("time-serie-add-back-filling", options)
	client.Add("time-serie-add-back-filling", 1, 1)
	client.Add("time-serie-add-back-filling", 2, 1)
	client.Add("time-serie-add-back-filling", 4, 1)
	client.Add("time-serie-add-back-filling", 3, 1)
	datapoints, _ := client.RangeWithOptions("time-serie-add-back-filling", 0, 1000, redistimeseries.DefaultRangeOptions)
	fmt.Printf("Datapoints: %v\n", datapoints)
}
func ExampleClient_Add_duplicateDatapointsLastDuplicatePolicy() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client-1")
	options := redistimeseries.DefaultCreateOptions
	options.DuplicatePolicy = redistimeseries.LastDuplicatePolicy
	client.CreateKeyWithOptions("time-series-add-duplicate-last", options)
	client.Add("time-series-add-duplicate-last", 1, 1.0)
	client.Add("time-series-add-duplicate-last", 1, 10.0)
	latestDatapoint, _ := client.Get("time-series-add-duplicate-last")
	fmt.Printf("Latest datapoint: timestamp=%d value=%f\n", latestDatapoint.Timestamp, latestDatapoint.Value)
}
func ExampleClient_Add_minDuplicatePolicy() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client-1")
	options := redistimeseries.DefaultCreateOptions
	options.DuplicatePolicy = redistimeseries.MinDuplicatePolicy
	client.CreateKeyWithOptions("time-series-add-duplicate-min", options)
	client.Add("time-series-add-duplicate-min", 1, 1.0)
	client.Add("time-series-add-duplicate-min", 1, 10.0)
	minDatapoint, _ := client.Get("time-series-add-duplicate-min")
	fmt.Printf("Minimal datapoint: timestamp=%d value=%f\n", minDatapoint.Timestamp, minDatapoint.Value)
}
func ExampleClient_AddWithOptions() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client")
	labels := map[string]string{
		"machine": "machine-1",
		"az":      "us-west-2",
	}
	options := redistimeseries.DefaultCreateOptions
	options.Labels = labels
	client.AddWithOptions("time-series-example-add", 1, 1, options)
	client.AddWithOptions("time-series-example-add", 2, 2, options)
	latestDatapoint, _ := client.Get("time-series-example-add")
	fmt.Printf("Latest datapoint: timestamp=%d value=%f\n", latestDatapoint.Timestamp, latestDatapoint.Value)
}
func ExampleClient_AddWithOptions_duplicateDatapointsLastDuplicatePolicy() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client")
	labels := map[string]string{
		"machine": "machine-1",
		"az":      "us-west-2",
	}
	options := redistimeseries.DefaultCreateOptions
	options.DuplicatePolicy = redistimeseries.LastDuplicatePolicy
	options.Labels = labels
	client.AddWithOptions("time-series-example-duplicate", 1, 1, options)
	client.AddWithOptions("time-series-example-duplicate", 1, 10, options)
	latestDatapoint, _ := client.Get("time-series-example-duplicate")
	options.DuplicatePolicy = redistimeseries.MinDuplicatePolicy
	client.AddWithOptions("time-series-example-duplicate", 1, 15, options)
	minDatapoint, _ := client.Get("time-series-example-duplicate")
	fmt.Printf("Latest datapoint: timestamp=%d value=%f\n", latestDatapoint.Timestamp, latestDatapoint.Value)
	fmt.Printf("Minimal datapoint: timestamp=%d value=%f\n", minDatapoint.Timestamp, minDatapoint.Value)
}
func ExampleClient_AddWithOptions_duplicateDatapointsMaxDuplicatePolicy() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client")
	labels := map[string]string{
		"machine": "machine-1",
		"az":      "us-west-2",
	}
	options := redistimeseries.DefaultCreateOptions
	options.DuplicatePolicy = redistimeseries.MaxDuplicatePolicy
	options.Labels = labels
	client.AddWithOptions("time-series-example-duplicate-max", 1, 10.0, options)
	client.AddWithOptions("time-series-example-duplicate-max", 1, 5.0, options)
	latestDatapoint, _ := client.Get("time-series-example-duplicate-max")
	fmt.Printf("Latest datapoint: timestamp=%d value=%f\n", latestDatapoint.Timestamp, latestDatapoint.Value)
}
func ExampleClient_AddWithOptions_backFilling() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client")
	labels := map[string]string{
		"machine": "machine-1",
		"az":      "us-west-2",
	}
	options := redistimeseries.DefaultCreateOptions
	options.Labels = labels
	client.AddWithOptions("time-series-example-back-filling", 1, 1, options)
	client.AddWithOptions("time-series-example-back-filling", 2, 1, options)
	client.AddWithOptions("time-series-example-back-filling", 4, 1, options)
	client.AddWithOptions("time-series-example-back-filling", 3, 1, options)
	datapoints, _ := client.RangeWithOptions("time-series-example-back-filling", 0, 1000, redistimeseries.DefaultRangeOptions)
	fmt.Printf("Datapoints: %v\n", datapoints)
}
func ExampleClient_RangeWithOptions() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client-1")
	for ts := 1; ts < 10; ts++ {
		client.Add("ts-1", int64(ts), float64(ts))
	}
	datapoints, _ := client.RangeWithOptions("ts-1", 0, 1000, redistimeseries.DefaultRangeOptions)
	fmt.Printf("Datapoints: %v\n", datapoints)
}
func ExampleClient_RangeWithOptions_aggregationMax() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client-1")
	for ts := 1; ts < 10; ts++ {
		client.Add("ts-1", int64(ts), float64(ts))
	}
	datapoints, _ := client.RangeWithOptions("ts-1", 0, 1000, *redistimeseries.NewRangeOptions().SetAggregation(redistimeseries.MaxAggregation, 5))
	fmt.Printf("Datapoints: %v\n", datapoints)
}
func ExampleClient_RangeWithOptions_aggregationAlign() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client-1")
	for ts := 1; ts < 10; ts++ {
		client.Add("ts-1", int64(ts), float64(ts))
	}
	datapoints, _ := client.RangeWithOptions("ts-1", 0, 1000, *redistimeseries.NewRangeOptions().SetAggregation(redistimeseries.CountAggregation, 2).SetAlign(1))
	fmt.Printf("Datapoints: %v\n", datapoints)
}
func ExampleClient_ReverseRangeWithOptions() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client-1")
	for ts := 1; ts < 10; ts++ {
		client.Add("ts-2", int64(ts), float64(ts))
	}
	datapoints, _ := client.ReverseRangeWithOptions("ts-2", 0, 1000, redistimeseries.DefaultRangeOptions)
	fmt.Printf("Datapoints: %v\n", datapoints)
}
func ExampleClient_ReverseRangeWithOptions_filterByValue() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client-1")
	for ts := 1; ts < 10; ts++ {
		client.Add("ts-2", int64(ts), float64(ts))
	}
	datapoints, _ := client.ReverseRangeWithOptions("ts-2", 0, 1000, *redistimeseries.NewRangeOptions().SetFilterByValue(5, 50))
	fmt.Printf("Datapoints: %v\n", datapoints)
}
func ExampleClient_ReverseRangeWithOptions_filterByTs() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client-1")
	for ts := 1; ts < 10; ts++ {
		client.Add("ts-2", int64(ts), float64(ts))
	}
	datapoints, _ := client.ReverseRangeWithOptions("ts-2", 0, 1000, *redistimeseries.NewRangeOptions().SetFilterByTs([]int64{1, 2, 3, 4, 5}))
	fmt.Printf("Datapoints: %v\n", datapoints)
}
func ExampleClient_MultiRangeWithOptions() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client-1")
	client.FlushAll()
	labels1 := map[string]string{
		"machine": "machine-1",
		"az":      "us-east-1",
	}
	client.AddWithOptions("time-serie-1", 2, 1.0, redistimeseries.CreateOptions{Labels: labels1})
	client.Add("time-serie-1", 4, 2.0)
	labels2 := map[string]string{
		"machine": "machine-2",
		"az":      "us-east-1",
	}
	client.AddWithOptions("time-serie-2", 1, 5.0, redistimeseries.CreateOptions{Labels: labels2})
	client.Add("time-serie-2", 4, 10.0)
	ranges, _ := client.MultiRangeWithOptions(1, 10, redistimeseries.DefaultMultiRangeOptions, "az=us-east-1")
	fmt.Printf("Ranges: %v\n", ranges)
}
func ExampleClient_MultiRangeWithOptions_groupByReduce() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client-1")
	client.FlushAll()
	labels1 := map[string]string{
		"machine": "machine-1",
		"az":      "us-east-1",
		"team":    "team-1",
	}
	client.AddWithOptions("time-serie-1", 2, 1.0, redistimeseries.CreateOptions{Labels: labels1})
	client.Add("time-serie-1", 4, 2.0)
	labels2 := map[string]string{
		"machine": "machine-2",
		"az":      "us-east-1",
		"team":    "team-2",
	}
	client.AddWithOptions("time-serie-2", 1, 5.0, redistimeseries.CreateOptions{Labels: labels2})
	client.Add("time-serie-2", 4, 10.0)
	labels3 := map[string]string{
		"machine": "machine-3",
		"az":      "us-east-1",
		"team":    "team-2",
	}
	client.AddWithOptions("time-serie-3", 1, 55.0, redistimeseries.CreateOptions{Labels: labels3})
	client.Add("time-serie-3", 4, 99.0)
	ranges, _ := client.MultiRangeWithOptions(1, 10, *redistimeseries.NewMultiRangeOptions().SetWithLabels(true).SetGroupByReduce("team", redistimeseries.SumReducer), "az=us-east-1")
	fmt.Printf("Sum of usage by team: %v\n", ranges)
}
func ExampleClient_MultiRangeWithOptions_filterByTs() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client-1")
	client.FlushAll()
	labels1 := map[string]string{
		"machine": "machine-1",
		"az":      "us-east-1",
	}
	client.AddWithOptions("time-serie-1", 2, 1.0, redistimeseries.CreateOptions{Labels: labels1})
	client.Add("time-serie-1", 4, 2.0)
	labels2 := map[string]string{
		"machine": "machine-2",
		"az":      "us-east-1",
	}
	client.AddWithOptions("time-serie-2", 1, 5.0, redistimeseries.CreateOptions{Labels: labels2})
	client.Add("time-serie-2", 4, 10.0)
	ranges, _ := client.MultiRangeWithOptions(1, 10, *redistimeseries.NewMultiRangeOptions().SetFilterByTs([]int64{1, 2}), "az=us-east-1")
	fmt.Printf("Ranges: %v\n", ranges)
}
func ExampleClient_MultiRangeWithOptions_filterByValue() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client-1")
	client.FlushAll()
	labels1 := map[string]string{
		"machine": "machine-1",
		"az":      "us-east-1",
	}
	client.AddWithOptions("time-serie-1", 2, 1.0, redistimeseries.CreateOptions{Labels: labels1})
	client.Add("time-serie-1", 4, 2.0)
	labels2 := map[string]string{
		"machine": "machine-2",
		"az":      "us-east-1",
	}
	client.AddWithOptions("time-serie-2", 1, 2.0, redistimeseries.CreateOptions{Labels: labels2})
	client.Add("time-serie-2", 4, 10.0)
	ranges, _ := client.MultiRangeWithOptions(1, 10, *redistimeseries.NewMultiRangeOptions().SetFilterByValue(1, 5), "az=us-east-1")
	fmt.Printf("Ranges: %v\n", ranges)
}
func ExampleClient_MultiRangeWithOptions_selectedLabels() {
	host := "localhost:6379"
	password := ""
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host, redis.DialPassword(password))
	}}
	client := redistimeseries.NewClientFromPool(pool, "ts-client-1")
	client.FlushAll()
	labels1 := map[string]string{
		"machine":  "machine-1",
		"team":     "SF-1",
		"location": "SF",
		"az":       "us-east-1",
	}
	client.AddWithOptions("selected-labels-ex-time-serie-1", 2, 1.0, redistimeseries.CreateOptions{Labels: labels1})
	client.Add("selected-labels-ex-time-serie-1", 4, 2.0)
	labels2 := map[string]string{
		"machine":  "machine-2",
		"team":     "NY-1",
		"location": "NY",
		"az":       "us-east-1",
	}
	client.AddWithOptions("selected-labels-ex-time-serie-2", 1, 10.0, redistimeseries.CreateOptions{Labels: labels2})
	client.Add("selected-labels-ex-time-serie-2", 4, 15.0)
	ranges, _ := client.MultiRangeWithOptions(1, 10, *redistimeseries.NewMultiRangeOptions().SetSelectedLabels([]string{"az", "location"}), "az=us-east-1")
	fmt.Printf("Ranges: %v\n", ranges)
}