Home

Awesome

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

CommandRecommended API and godoc
TS.CREATECreateKeyWithOptions
TS.ALTERAlterKeyWithOptions
TS.ADD<ul><li>Add</li><li>AddAutoTs</li><li>AddWithOptions</li><li>AddAutoTsWithOptions</li> </ul>
TS.MADDMultiAdd
TS.INCRBY/TS.DECRBYIncrBy / DecrBy
TS.CREATERULECreateRule
TS.DELETERULEDeleteRule
TS.RANGERangeWithOptions
TS.REVRANGEReverseRangeWithOptions
TS.MRANGEMultiRangeWithOptions
TS.MREVRANGEMultiReverseRangeWithOptions
TS.GETGet
TS.MGET<ul><li>MultiGet</li><li> MultiGetWithOptions </li> </ul>
TS.INFOInfo
TS.QUERYINDEXQueryIndex

License

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