Home

Awesome

license GitHub issues Codecov GoDoc Go Report Card

redisbloom-go

Forum Discord

Go client for RedisBloom (https://github.com/RedisBloom/redisbloom), based on redigo.

Installing

$ go get github.com/RedisBloom/redisbloom-go

Running tests

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

$ go test

The tests expect a Redis server with the RedisBloom module loaded to be available at localhost:6379. You can easily launch RedisBloom with Docker in the following manner:

docker run -d -p 6379:6379 --name redis-redisbloom redis/redis-stack-server:latest

Example Code

Make sure to check the full list of examples at Pkg.go.dev.

package main

import (
        "fmt"
        redisbloom "github.com/RedisBloom/redisbloom-go"
)

func main() {
    // Connect to localhost with no password
    var client = redisbloom.NewClient("localhost:6379", "nohelp", nil)

    // BF.ADD mytest item
    _, err := client.Add("mytest", "myItem")
    if err != nil {
        fmt.Println("Error:", err)
    }

    exists, err := client.Exists("mytest", "myItem")
    if err != nil {
        fmt.Println("Error:", err)
    }
    fmt.Println("myItem exists in mytest: ", exists)
}

Supported RedisBloom Commands

Make sure to check the full command reference at redisbloom.io.

Bloom Filter

CommandRecommended API and godoc
BF.RESERVEReserve
BF.ADDAdd
BF.MADDBfAddMulti
BF.INSERTBfInsert
BF.EXISTSExists
BF.MEXISTSBfExistsMulti
BF.SCANDUMPBfScanDump
BF.LOADCHUNKBfLoadChunk
BF.INFOInfo

Cuckoo Filter

CommandRecommended API and godoc
CF.RESERVECfReserve
CF.ADDCfAdd
CF.ADDNXCfAddNx
CF.INSERTCfInsert
CF.INSERTNXCfInsertNx
CF.EXISTSCfExists
CF.DELCfDel
CF.COUNTCfCount
CF.SCANDUMPCfScanDump
CF.LOADCHUNKCfLoadChunk
CF.INFOCfInfo

Count-Min Sketch

CommandRecommended API and godoc
CMS.INITBYDIMCmsInitByDim
CMS.INITBYPROBCmsInitByProb
CMS.INCRBYCmsIncrBy
CMS.QUERYCmsQuery
CMS.MERGECmsMerge
CMS.INFOCmsInfo

TopK Filter

CommandRecommended API and godoc
TOPK.RESERVETopkReserve
TOPK.ADDTopkAdd
TOPK.INCRBYTopkIncrby
TOPK.QUERYTopkQuery
TOPK.COUNTTopkCount
TOPK.LISTTopkList
TOPK.INFOTopkInfo

License

redisbloom-go is distributed under the BSD 3-Clause license - see LICENSE