https://github.com/redistimeseries/redistimeseries-go
golang client lib for RedisTimeSeries
https://github.com/redistimeseries/redistimeseries-go
golang redis redis-client timeseries
Last synced: 11 months ago
JSON representation
golang client lib for RedisTimeSeries
- Host: GitHub
- URL: https://github.com/redistimeseries/redistimeseries-go
- Owner: RedisTimeSeries
- License: apache-2.0
- Created: 2018-11-11T10:18:49.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-09-10T19:09:01.000Z (over 1 year ago)
- Last Synced: 2025-06-02T02:04:23.955Z (about 1 year ago)
- Topics: golang, redis, redis-client, timeseries
- Language: Go
- Homepage: https://redistimeseries.io
- Size: 301 KB
- Stars: 66
- Watchers: 10
- Forks: 18
- Open Issues: 41
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/RedisTimeSeries/RedisTimeSeries-go)
[](https://circleci.com/gh/RedisTimeSeries/redistimeseries-go)
[](https://github.com/RedisTimeSeries/redistimeseries-go/releases/latest)
[](https://codecov.io/gh/RedisTimeSeries/redistimeseries-go)
[](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go)
[](https://goreportcard.com/report/github.com/RedisTimeSeries/redistimeseries-go)
[](https://lgtm.com/projects/g/RedisTimeSeries/redistimeseries-go/alerts/)
# redistimeseries-go
[](https://forum.redislabs.com/c/modules/redistimeseries)
[](https://discord.gg/KExRgMb)
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
```sh
$ go get github.com/RedisTimeSeries/redistimeseries-go
```
## Running tests
A simple test suite is provided, and can be run with:
```sh
$ go test
```
The tests expect a Redis server with the RedisTimeSeries module loaded to be available at localhost:6379
## Example Code
```go
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](https://oss.redislabs.com/redistimeseries/commands/#tscreate) | [CreateKeyWithOptions](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.CreateKeyWithOptions) |
| [TS.ALTER](https://oss.redislabs.com/redistimeseries/commands/#tsalter) | [AlterKeyWithOptions](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.AlterKeyWithOptions) |
| [TS.ADD](https://oss.redislabs.com/redistimeseries/commands/#tsadd) |
- [Add](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.Add)
- [AddAutoTs](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.AddAutoTs)
- [AddWithOptions](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.AddWithOptions)
- [AddAutoTsWithOptions](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.AddWithOptions)
| [TS.MADD](https://oss.redislabs.com/redistimeseries/commands/#tsmadd) | [MultiAdd](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.MultiAdd) |
| [TS.INCRBY/TS.DECRBY](https://oss.redislabs.com/redistimeseries/commands/#tsincrbytsdecrby) | [IncrBy](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.IncrBy) / [DecrBy](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.DecrBy) |
| [TS.CREATERULE](https://oss.redislabs.com/redistimeseries/commands/#tscreaterule) | [CreateRule](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.CreateRule) |
| [TS.DELETERULE](https://oss.redislabs.com/redistimeseries/commands/#tsdeleterule) | [DeleteRule](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.DeleteRule) |
| [TS.RANGE](https://oss.redislabs.com/redistimeseries/commands/#tsrangetsrevrange) | [RangeWithOptions](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.RangeWithOptions) |
| [TS.REVRANGE](https://oss.redislabs.com/redistimeseries/commands/#tsrangetsrevrange) | [ReverseRangeWithOptions](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.ReverseRangeWithOptions) |
| [TS.MRANGE](https://oss.redislabs.com/redistimeseries/commands/#tsmrangetsmrevrange) | [MultiRangeWithOptions](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.MultiRangeWithOptions) |
| [TS.MREVRANGE](https://oss.redislabs.com/redistimeseries/commands/#tsmrangetsmrevrange) | [MultiReverseRangeWithOptions](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.MultiReverseRangeWithOptions) |
| [TS.GET](https://oss.redislabs.com/redistimeseries/commands/#tsget) | [Get](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.Get) |
| [TS.MGET](https://oss.redislabs.com/redistimeseries/commands/#tsmget) |
- [MultiGet](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.MultiGet)
- [MultiGetWithOptions](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.MultiGetWithOptions)
| [TS.INFO](https://oss.redislabs.com/redistimeseries/commands/#tsinfo) | [Info](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.Info) |
| [TS.QUERYINDEX](https://oss.redislabs.com/redistimeseries/commands/#tsqueryindex) | [QueryIndex](https://godoc.org/github.com/RedisTimeSeries/redistimeseries-go#Client.QueryIndex) |
## License
redistimeseries-go is distributed under the Apache-2 license - see [LICENSE](LICENSE)