@@ -22,40 +22,59 @@ $ go get github.com/RedisTimeSeries/redistimeseries-go
2222A simple test suite is provided, and can be run with:
2323
2424``` sh
25- $ go test
25+ $ REDISTIMESERIES_TEST_PASSWORD= " " go test
2626```
2727
2828The tests expect a Redis server with the RedisTimeSeries module loaded to be available at localhost:6379
2929
3030## Example Code
3131
32- ```
32+ ``` go
33+ package main
34+
3335import (
3436 " fmt"
35- "github.com/RedisTimeSeries/redistimeseries-go"
36- "time"
37+ redistimeseries " github.com/RedisTimeSeries/redistimeseries-go"
3738)
3839
3940func main () {
40- // Connect to localhost with no password
41- var client = redis_timeseries_go.NewClient("localhost:6379", "nohelp", nil)
42- var duration, _ = time.ParseDuration("1m")
41+ // Connect to localhost with no password
42+ var client = redistimeseries.NewClient (" localhost:6379" , " nohelp" , nil )
4343 var keyname = " mytest"
44- _, havit := client.Info(keyname)
45- if havit != nil {
46- client.CreateKey (keyname, duration )
47- client.CreateKey (keyname+"_avg", 0 )
48- client.CreateRule(keyname, redis_timeseries_go .AvgAggregation, 60, keyname+"_avg")
44+ _ , haveit := client.Info (keyname)
45+ if haveit != nil {
46+ client.CreateKeyWithOptions (keyname, redistimeseries. DefaultCreateOptions )
47+ client.CreateKeyWithOptions (keyname+" _avg" , redistimeseries. DefaultCreateOptions )
48+ client.CreateRule (keyname, redistimeseries .AvgAggregation , 60 , keyname+" _avg" )
4949 }
50- now := time.Now().UnixNano() / 1e6 // now in ms
51- err := client.Add(keyname, now, 100)
50+ // Add sample with timestamp from server time and value 100
51+ // TS.ADD mytest * 100
52+ _ , err := client.AddAutoTs (keyname, 100 )
5253 if err != nil {
5354 fmt.Println (" Error:" , err)
5455 }
55-
5656}
5757```
5858
59+ ## Supported RedisTimeSeries Commands
60+
61+ | Command | Recommended API and godoc |
62+ | :--- | ----: |
63+ | [ TS.CREATE] ( https://oss.redislabs.com/redistimeseries/commands/#tscreate ) | [ CreateKeyWithOptions] ( https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.CreateKeyWithOptions ) |
64+ | [ TS.ALTER] ( https://oss.redislabs.com/redistimeseries/commands/#tsalter ) | N/A |
65+ | [ TS.ADD] ( https://oss.redislabs.com/redistimeseries/commands/#tsadd ) | <ul ><li >[ Add] ( https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.Add ) </li ><li >[ AddAutoTs] ( https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.AddAutoTs ) </li ><li >[ AddWithOptions] ( https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.AddWithOptions ) </li ><li >[ AddAutoTsWithOptions] ( https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.AddWithOptions ) </li > </ul > |
66+ | [ TS.MADD] ( https://oss.redislabs.com/redistimeseries/commands/#tsmadd ) | N/A |
67+ | [ TS.INCRBY/TS.DECRBY] ( https://oss.redislabs.com/redistimeseries/commands/#tsincrbytsdecrby ) | N/A |
68+ | [ TS.CREATERULE] ( https://oss.redislabs.com/redistimeseries/commands/#tscreaterule ) | [ CreateRule] ( https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.CreateRule ) |
69+ | [ TS.DELETERULE] ( https://oss.redislabs.com/redistimeseries/commands/#tsdeleterule ) | [ DeleteRule] ( https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.DeleteRule ) |
70+ | [ TS.RANGE] ( https://oss.redislabs.com/redistimeseries/commands/#tsrange ) | [ RangeWithOptions] ( https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.RangeWithOptions ) |
71+ | [ TS.MRANGE] ( https://oss.redislabs.com/redistimeseries/commands/#tsmrange ) | [ MultiRangeWithOptions] ( https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.MultiRangeWithOptions ) |
72+ | [ TS.GET] ( https://oss.redislabs.com/redistimeseries/commands/#tsget ) | [ Get] ( https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.Get ) |
73+ | [ TS.MGET] ( https://oss.redislabs.com/redistimeseries/commands/#tsmget ) | [ MultiGet] ( https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.MultiGet ) |
74+ | [ TS.INFO] ( https://oss.redislabs.com/redistimeseries/commands/#tsinfo ) | [ Info] ( https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.Info ) |
75+ | [ TS.QUERYINDEX] ( https://oss.redislabs.com/redistimeseries/commands/#tsqueryindex ) | N/A |
76+
77+
5978## License
6079
6180redistimeseries-go is distributed under the Apache-2 license - see [ LICENSE] ( LICENSE )
0 commit comments