|
| 1 | +[](https://github.com/RedisBloom/redisbloom-go) |
| 2 | +[](https://circleci.com/gh/RedisBloom/redisbloom-go) |
| 3 | +[](https://github.com/RedisBloom/redisbloom-go/releases/latest) |
| 4 | +[](https://codecov.io/gh/RedisBloom/redisbloom-go) |
| 5 | +[](https://godoc.org/github.com/RedisBloom/redisbloom-go) |
| 6 | + |
| 7 | + |
| 8 | +# redisbloom-go |
| 9 | + |
| 10 | +Go client for RedisBloom (https://github.com/RedisBloom/redisbloom), based on redigo. |
| 11 | + |
| 12 | +## Installing |
| 13 | + |
| 14 | +```sh |
| 15 | +$ go get github.com/RedisBloom/redisbloom-go |
| 16 | +``` |
| 17 | + |
| 18 | +## Running tests |
| 19 | + |
| 20 | +A simple test suite is provided, and can be run with: |
| 21 | + |
| 22 | +```sh |
| 23 | +$ RedisBloom_TEST_PASSWORD="" go test |
| 24 | +``` |
| 25 | + |
| 26 | +The tests expect a Redis server with the RedisBloom module loaded to be available at localhost:6379 |
| 27 | + |
| 28 | +## Example Code |
| 29 | + |
| 30 | +```go |
| 31 | +package main |
| 32 | + |
| 33 | +import ( |
| 34 | + "fmt" |
| 35 | + RedisBloom "github.com/RedisBloom/redisbloom-go" |
| 36 | +) |
| 37 | + |
| 38 | +func main() { |
| 39 | + // Connect to localhost with no password |
| 40 | + var client = RedisBloom.NewClient("localhost:6379", "nohelp", nil) |
| 41 | + var keyname = "mytest" |
| 42 | + _, haveit := client.Info(keyname) |
| 43 | + if haveit != nil { |
| 44 | + client.CreateKeyWithOptions(keyname, RedisBloom.DefaultCreateOptions) |
| 45 | + client.CreateKeyWithOptions(keyname+"_avg", RedisBloom.DefaultCreateOptions) |
| 46 | + client.CreateRule(keyname, RedisBloom.AvgAggregation, 60, keyname+"_avg") |
| 47 | + } |
| 48 | + // Add sample with timestamp from server time and value 100 |
| 49 | + // TS.ADD mytest * 100 |
| 50 | + _, err := client.AddAutoTs(keyname, 100) |
| 51 | + if err != nil { |
| 52 | + fmt.Println("Error:", err) |
| 53 | + } |
| 54 | +} |
| 55 | +``` |
| 56 | + |
| 57 | +## Supported RedisBloom Commands |
| 58 | + |
| 59 | +| Command | Recommended API and godoc | |
| 60 | +| :--- | ----: | |
| 61 | +| [TS.CREATE](https://oss.redislabs.com/RedisBloom/commands/#tscreate) | [CreateKeyWithOptions](https://godoc.org/github.com/RedisBloom/redisbloom-go#Client.CreateKeyWithOptions) | |
| 62 | +| [TS.ALTER](https://oss.redislabs.com/RedisBloom/commands/#tsalter) | N/A | |
| 63 | +| [TS.ADD](https://oss.redislabs.com/RedisBloom/commands/#tsadd) | <ul><li>[Add](https://godoc.org/github.com/RedisBloom/redisbloom-go#Client.Add)</li><li>[AddAutoTs](https://godoc.org/github.com/RedisBloom/redisbloom-go#Client.AddAutoTs)</li><li>[AddWithOptions](https://godoc.org/github.com/RedisBloom/redisbloom-go#Client.AddWithOptions)</li><li>[AddAutoTsWithOptions](https://godoc.org/github.com/RedisBloom/redisbloom-go#Client.AddWithOptions)</li> </ul> | |
| 64 | +| [TS.MADD](https://oss.redislabs.com/RedisBloom/commands/#tsmadd) | N/A | |
| 65 | +| [TS.INCRBY/TS.DECRBY](https://oss.redislabs.com/RedisBloom/commands/#tsincrbytsdecrby) | N/A | |
| 66 | +| [TS.CREATERULE](https://oss.redislabs.com/RedisBloom/commands/#tscreaterule) | [CreateRule](https://godoc.org/github.com/RedisBloom/redisbloom-go#Client.CreateRule) | |
| 67 | +| [TS.DELETERULE](https://oss.redislabs.com/RedisBloom/commands/#tsdeleterule) | [DeleteRule](https://godoc.org/github.com/RedisBloom/redisbloom-go#Client.DeleteRule) | |
| 68 | +| [TS.RANGE](https://oss.redislabs.com/RedisBloom/commands/#tsrange) | [RangeWithOptions](https://godoc.org/github.com/RedisBloom/redisbloom-go#Client.RangeWithOptions) | |
| 69 | +| [TS.MRANGE](https://oss.redislabs.com/RedisBloom/commands/#tsmrange) | [MultiRangeWithOptions](https://godoc.org/github.com/RedisBloom/redisbloom-go#Client.MultiRangeWithOptions) | |
| 70 | +| [TS.GET](https://oss.redislabs.com/RedisBloom/commands/#tsget) | [Get](https://godoc.org/github.com/RedisBloom/redisbloom-go#Client.Get) | |
| 71 | +| [TS.MGET](https://oss.redislabs.com/RedisBloom/commands/#tsmget) | [MultiGet](https://godoc.org/github.com/RedisBloom/redisbloom-go#Client.MultiGet) | |
| 72 | +| [TS.INFO](https://oss.redislabs.com/RedisBloom/commands/#tsinfo) | [Info](https://godoc.org/github.com/RedisBloom/redisbloom-go#Client.Info) | |
| 73 | +| [TS.QUERYINDEX](https://oss.redislabs.com/RedisBloom/commands/#tsqueryindex) | N/A | |
| 74 | + |
| 75 | + |
| 76 | +## License |
| 77 | + |
| 78 | +redisbloom-go is distributed under the Apache-2 license - see [LICENSE](LICENSE) |
0 commit comments