项目作者: RedisTimeSeries

项目描述 :
golang client lib for RedisTimeSeries
高级语言: Go
项目地址: git://github.com/RedisTimeSeries/redistimeseries-go.git
创建时间: 2018-11-11T10:18:49Z
项目社区:https://github.com/RedisTimeSeries/redistimeseries-go

开源协议:Apache License 2.0

下载


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

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

Running tests

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

  1. $ go test

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

Example Code

  1. package main
  2. import (
  3. "fmt"
  4. redistimeseries "github.com/RedisTimeSeries/redistimeseries-go"
  5. )
  6. func main() {
  7. // Connect to localhost with no password
  8. var client = redistimeseries.NewClient("localhost:6379", "nohelp", nil)
  9. var keyname = "mytest"
  10. _, haveit := client.Info(keyname)
  11. if haveit != nil {
  12. client.CreateKeyWithOptions(keyname, redistimeseries.DefaultCreateOptions)
  13. client.CreateKeyWithOptions(keyname+"_avg", redistimeseries.DefaultCreateOptions)
  14. client.CreateRule(keyname, redistimeseries.AvgAggregation, 60, keyname+"_avg")
  15. }
  16. // Add sample with timestamp from server time and value 100
  17. // TS.ADD mytest * 100
  18. _, err := client.AddAutoTs(keyname, 100)
  19. if err != nil {
  20. fmt.Println("Error:", err)
  21. }
  22. }

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