Skip to content

RedisTimeSeries/redistimeseries-go

Folders and files

NameName
Last commit message
Last commit date
Jul 21, 2021
Jul 21, 2021
Jan 12, 2020
Aug 8, 2023
Oct 8, 2018
Aug 4, 2021
Nov 3, 2020
Aug 4, 2021
Aug 11, 2021
Aug 12, 2021
Sep 17, 2020
Aug 12, 2021
Aug 3, 2020
Aug 3, 2020
Aug 3, 2020
Jul 19, 2020
Aug 4, 2021
Aug 4, 2021
Jul 19, 2020
Aug 3, 2020
Aug 4, 2021
Aug 4, 2021
Sep 17, 2020
Jul 19, 2020
Jan 27, 2020

Repository files navigation

license CircleCI GitHub issues Codecov GoDoc Go Report Card Total alerts

redistimeseries-go

Forum Discord

Go client for RedisTimeSeries (https://github.com/RedisTimeSeries/redistimeseries), based on redigo.

Client and ConnPool based on the work of dvirsky and mnunberg on https://github.com/RediSearch/redisearch-go

Installing

$ go get github.com/RedisTimeSeries/redistimeseries-go

Running tests

A simple test suite is provided, and can be run with:

$ go test

The tests expect a Redis server with the RedisTimeSeries module loaded to be available at localhost:6379

Example Code

package main 

import (
        "fmt"
        redistimeseries "github.com/RedisTimeSeries/redistimeseries-go"
)

func main() {
		// Connect to localhost with no password
        var client = redistimeseries.NewClient("localhost:6379", "nohelp", nil)
        var keyname = "mytest"
        _, haveit := client.Info(keyname)
        if haveit != nil {
			client.CreateKeyWithOptions(keyname, redistimeseries.DefaultCreateOptions)
			client.CreateKeyWithOptions(keyname+"_avg", redistimeseries.DefaultCreateOptions)
			client.CreateRule(keyname, redistimeseries.AvgAggregation, 60, keyname+"_avg")
        }
		// Add sample with timestamp from server time and value 100
        // TS.ADD mytest * 100 
        _, err := client.AddAutoTs(keyname, 100)
        if err != nil {
                fmt.Println("Error:", err)
        }
}

Supported RedisTimeSeries Commands

Command Recommended API and godoc
TS.CREATE CreateKeyWithOptions
TS.ALTER AlterKeyWithOptions
TS.ADD
TS.MADD MultiAdd
TS.INCRBY/TS.DECRBY IncrBy / DecrBy
TS.CREATERULE CreateRule
TS.DELETERULE DeleteRule
TS.RANGE RangeWithOptions
TS.REVRANGE ReverseRangeWithOptions
TS.MRANGE MultiRangeWithOptions
TS.MREVRANGE MultiReverseRangeWithOptions
TS.GET Get
TS.MGET
TS.INFO Info
TS.QUERYINDEX QueryIndex

License

redistimeseries-go is distributed under the Apache-2 license - see LICENSE