Documentation ¶
Index ¶
- func GetInsertArgs(key string, cap int64, noCreate bool, items []string) redis.Args
- func ParseInfoReply(values []interface{}, err error) (map[string]int64, error)
- type Client
- func (client *Client) Add(key string, item string) (exists bool, err error)
- func (client *Client) BfAddMulti(key string, items []string) ([]int64, error)
- func (client *Client) BfExistsMulti(key string, items []string) ([]int64, error)
- func (client *Client) BfInsert(key string, cap int64, errorRatio float64, expansion int64, noCreate bool, ...) (res []int64, err error)
- func (client *Client) BfLoadChunk(key string, iter int64, data []byte) (string, error)
- func (client *Client) BfScanDump(key string, iter int64) (int64, []byte, error)
- func (client *Client) CfAdd(key string, item string) (bool, error)
- func (client *Client) CfAddNx(key string, item string) (bool, error)
- func (client *Client) CfCount(key string, item string) (int64, error)
- func (client *Client) CfDel(key string, item string) (bool, error)
- func (client *Client) CfExists(key string, item string) (bool, error)
- func (client *Client) CfInfo(key string) (map[string]int64, error)
- func (client *Client) CfInsert(key string, cap int64, noCreate bool, items []string) ([]int64, error)
- func (client *Client) CfInsertNx(key string, cap int64, noCreate bool, items []string) ([]int64, error)
- func (client *Client) CfLoadChunk(key string, iter int64, data []byte) (string, error)
- func (client *Client) CfReserve(key string, capacity int64, bucketSize int64, maxIterations int64, ...) (string, error)
- func (client *Client) CfScanDump(key string, iter int64) (int64, []byte, error)
- func (client *Client) CmsIncrBy(key string, itemIncrements map[string]int64) ([]int64, error)
- func (client *Client) CmsInfo(key string) (map[string]int64, error)
- func (client *Client) CmsInitByDim(key string, width int64, depth int64) (string, error)
- func (client *Client) CmsInitByProb(key string, error float64, probability float64) (string, error)
- func (client *Client) CmsMerge(dest string, srcs []string, weights []int64) (string, error)
- func (client *Client) CmsQuery(key string, items []string) ([]int64, error)
- func (client *Client) Exists(key string, item string) (exists bool, err error)
- func (client *Client) Info(key string) (info map[string]int64, err error)
- func (client *Client) Reserve(key string, error_rate float64, capacity uint64) (err error)
- func (client *Client) TdAdd(key string, samples map[float64]float64) (string, error)
- func (client *Client) TdCdf(key string, value float64) (float64, error)
- func (client *Client) TdCreate(key string, compression int64) (string, error)
- func (client *Client) TdInfo(key string) (TDigestInfo, error)
- func (client *Client) TdMax(key string) (float64, error)
- func (client *Client) TdMerge(toKey string, fromKey string) (string, error)
- func (client *Client) TdMin(key string) (float64, error)
- func (client *Client) TdQuantile(key string, quantile float64) (float64, error)
- func (client *Client) TdReset(key string) (string, error)
- func (client *Client) TopkAdd(key string, items []string) ([]string, error)
- func (client *Client) TopkCount(key string, items []string) (result []int64, err error)
- func (client *Client) TopkIncrBy(key string, itemIncrements map[string]int64) ([]string, error)
- func (client *Client) TopkInfo(key string) (map[string]string, error)
- func (client *Client) TopkList(key string) ([]string, error)
- func (client *Client) TopkQuery(key string, items []string) ([]int64, error)
- func (client *Client) TopkReserve(key string, topk int64, width int64, depth int64, decay float64) (string, error)
- type ConnPool
- type MultiHostPool
- type SingleHostPool
- type TDigestInfo
- func (info *TDigestInfo) Capacity() int64
- func (info *TDigestInfo) Compression() int64
- func (info *TDigestInfo) MergedNodes() int64
- func (info *TDigestInfo) MergedWeight() float64
- func (info *TDigestInfo) TotalCompressions() int64
- func (info *TDigestInfo) UnmergedNodes() int64
- func (info *TDigestInfo) UnmergedWeight() float64
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetInsertArgs ¶ added in v0.5.0
Types ¶
type Client ¶
Client is an interface to RedisBloom redis commands
func NewClient ¶
NewClient creates a new client connecting to the redis host, and using the given name as key prefix. Addr can be a single host:port pair, or a comma separated list of host:port,host:port... In the case of multiple hosts we create a multi-pool and select connections at random Deprecated: Please use NewClientFromPool() instead
Example ¶
exemplifies the NewClient function
package main import ( "fmt" redisbloom "github.com/RedisBloom/redisbloom-go" ) func main() { host := "localhost:6379" var client = redisbloom.NewClient(host, "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) }
Output: myItem exists in mytest: true
func NewClientFromPool ¶ added in v0.3.0
NewClientFromPool creates a new Client with the given pool and client name
Example ¶
exemplifies the NewClientFromPool function
package main import ( "fmt" redisbloom "github.com/RedisBloom/redisbloom-go" "github.com/gomodule/redigo/redis" "log" ) func main() { host := "localhost:6379" password := "" pool := &redis.Pool{Dial: func() (redis.Conn, error) { return redis.Dial("tcp", host, redis.DialPassword(password)) }} client := redisbloom.NewClientFromPool(pool, "bloom-client-1") // BF.ADD mytest item _, err := client.Add("mytest", "myItem") if err != nil { log.Fatalf("Error: %v", err) } exists, err := client.Exists("mytest", "myItem") if err != nil { log.Fatalf("Error: %v", err) } fmt.Println("myItem exists in mytest: ", exists) }
Output: myItem exists in mytest: true
func (*Client) Add ¶
Add - Add (or create and add) a new value to the filter args: key - the name of the filter item - the item to add
func (*Client) BfAddMulti ¶ added in v0.3.0
BfAddMulti - Adds one or more items to the Bloom Filter, creating the filter if it does not yet exist. args: key - the name of the filter item - One or more items to add
func (*Client) BfExistsMulti ¶ added in v0.3.0
BfExistsMulti - Determines if one or more items may exist in the filter or not. args: key - the name of the filter item - one or more items to check
func (*Client) BfInsert ¶ added in v0.9.0
func (client *Client) BfInsert(key string, cap int64, errorRatio float64, expansion int64, noCreate bool, nonScaling bool, items []string) (res []int64, err error)
This command will add one or more items to the bloom filter, by default creating it if it does not yet exist.
func (*Client) BfLoadChunk ¶ added in v0.9.0
Restores a filter previously saved using SCANDUMP .
func (*Client) BfScanDump ¶ added in v0.9.0
Begins an incremental save of the bloom filter.
func (*Client) CfAdd ¶ added in v0.5.0
Adds an item to the cuckoo filter, creating the filter if it does not exist.
func (*Client) CfAddNx ¶ added in v0.5.0
Adds an item to a cuckoo filter if the item did not exist previously.
func (*Client) CfInsert ¶ added in v0.5.0
func (client *Client) CfInsert(key string, cap int64, noCreate bool, items []string) ([]int64, error)
Adds one or more items to a cuckoo filter, allowing the filter to be created with a custom capacity if it does not yet exist.
func (*Client) CfInsertNx ¶ added in v0.5.0
func (client *Client) CfInsertNx(key string, cap int64, noCreate bool, items []string) ([]int64, error)
Adds one or more items to a cuckoo filter, allowing the filter to be created with a custom capacity if it does not yet exist.
func (*Client) CfLoadChunk ¶ added in v0.5.0
Restores a filter previously saved using SCANDUMP
func (*Client) CfReserve ¶ added in v0.5.0
func (client *Client) CfReserve(key string, capacity int64, bucketSize int64, maxIterations int64, expansion int64) (string, error)
Create an empty cuckoo filter with an initial capacity of {capacity} items.
func (*Client) CfScanDump ¶ added in v0.5.0
Begins an incremental save of the cuckoo filter.
func (*Client) CmsIncrBy ¶ added in v0.5.0
Increases the count of item by increment. Multiple items can be increased with one call.
func (*Client) CmsInitByDim ¶ added in v0.5.0
Initializes a Count-Min Sketch to dimensions specified by user.
func (*Client) CmsInitByProb ¶ added in v0.5.0
Initializes a Count-Min Sketch to accommodate requested capacity.
func (*Client) CmsMerge ¶ added in v0.5.0
Merges several sketches into one sketch, stored at dest key All sketches must have identical width and depth.
func (*Client) Exists ¶
Exists - Determines whether an item may exist in the Bloom Filter or not. args: key - the name of the filter item - the item to check for
func (*Client) Info ¶ added in v0.2.0
Info - Return information about key args: key - the name of the filter
func (*Client) Reserve ¶ added in v0.2.0
Reserve - Creates an empty Bloom Filter with a given desired error ratio and initial capacity. args: key - the name of the filter error_rate - the desired probability for false positives capacity - the number of entries you intend to add to the filter
func (*Client) TdAdd ¶ added in v1.0.0
TdAdd - Adds one or more samples to a sketch
Example ¶
exemplifies the TdAdd function
package main import ( "fmt" redisbloom "github.com/RedisBloom/redisbloom-go" ) func main() { host := "localhost:6379" var client = redisbloom.NewClient(host, "nohelp", nil) key := "example" ret, err := client.TdCreate(key, 100) if err != nil { fmt.Println("Error:", err) } samples := map[float64]float64{1.0: 1.0, 2.0: 2.0} ret, err = client.TdAdd(key, samples) if err != nil { fmt.Println("Error:", err) } fmt.Println(ret) }
Output: OK
func (*Client) TdCdf ¶ added in v1.0.0
TdCdf - Returns the fraction of all points added which are <= value
Example ¶
exemplifies the TdCdf function
package main import ( "fmt" redisbloom "github.com/RedisBloom/redisbloom-go" ) func main() { host := "localhost:6379" var client = redisbloom.NewClient(host, "nohelp", nil) key := "example" _, err := client.TdCreate(key, 10) if err != nil { fmt.Println("Error:", err) } samples := map[float64]float64{1.0: 1.0, 2.0: 1.0, 3.0: 1.0, 4.0: 1.0, 5.0: 1.0} _, err = client.TdAdd(key, samples) if err != nil { fmt.Println("Error:", err) } cdf, err := client.TdCdf(key, 1.0) if err != nil { fmt.Println("Error:", err) } fmt.Println(cdf) }
Output: 0.1
func (*Client) TdCreate ¶ added in v1.0.0
TdCreate - Allocate the memory and initialize the t-digest
Example ¶
exemplifies the TdCreate function
package main import ( "fmt" redisbloom "github.com/RedisBloom/redisbloom-go" ) func main() { host := "localhost:6379" var client = redisbloom.NewClient(host, "nohelp", nil) ret, err := client.TdCreate("key", 100) if err != nil { fmt.Println("Error:", err) } fmt.Println(ret) }
Output: OK
func (*Client) TdInfo ¶ added in v1.0.0
func (client *Client) TdInfo(key string) (TDigestInfo, error)
TdInfo - Returns compression, capacity, total merged and unmerged nodes, the total compressions made up to date on that key, and merged and unmerged weight.
func (*Client) TdMax ¶ added in v1.0.0
TdMax - Get maximum value from the sketch. Will return DBL_MIN if the sketch is empty
Example ¶
exemplifies the TdMax function
package main import ( "fmt" redisbloom "github.com/RedisBloom/redisbloom-go" ) func main() { host := "localhost:6379" var client = redisbloom.NewClient(host, "nohelp", nil) key := "example" _, err := client.TdCreate(key, 10) if err != nil { fmt.Println("Error:", err) } samples := map[float64]float64{1.0: 1.0, 2.0: 2.0, 3.0: 3.0} _, err = client.TdAdd(key, samples) if err != nil { fmt.Println("Error:", err) } max, err := client.TdMax(key) if err != nil { fmt.Println("Error:", err) } fmt.Println(max) }
Output: 3
func (*Client) TdMerge ¶ added in v1.0.0
TdMerge - Merges all of the values from 'from' to 'this' sketch
func (*Client) TdMin ¶ added in v1.0.0
TdMin - Get minimum value from the sketch. Will return DBL_MAX if the sketch is empty
Example ¶
exemplifies the TdMin function
package main import ( "fmt" redisbloom "github.com/RedisBloom/redisbloom-go" ) func main() { host := "localhost:6379" var client = redisbloom.NewClient(host, "nohelp", nil) key := "example" _, err := client.TdCreate(key, 10) if err != nil { fmt.Println("Error:", err) } samples := map[float64]float64{1.0: 1.0, 2.0: 2.0, 3.0: 3.0} _, err = client.TdAdd(key, samples) if err != nil { fmt.Println("Error:", err) } min, err := client.TdMin(key) if err != nil { fmt.Println("Error:", err) } fmt.Println(min) }
Output: 1
func (*Client) TdQuantile ¶ added in v1.0.0
TdQuantile - Returns an estimate of the cutoff such that a specified fraction of the data added to this TDigest would be less than or equal to the cutoff
Example ¶
exemplifies the TdQuantile function
package main import ( "fmt" redisbloom "github.com/RedisBloom/redisbloom-go" ) func main() { host := "localhost:6379" var client = redisbloom.NewClient(host, "nohelp", nil) key := "example" _, err := client.TdCreate(key, 10) if err != nil { fmt.Println("Error:", err) } samples := map[float64]float64{1.0: 1.0, 2.0: 1.0, 3.0: 1.0, 4.0: 1.0, 5.0: 1.0} _, err = client.TdAdd(key, samples) if err != nil { fmt.Println("Error:", err) } ans, err := client.TdQuantile(key, 1.0) if err != nil { fmt.Println("Error:", err) } fmt.Println(ans) }
Output: 5
func (*Client) TdReset ¶ added in v1.0.0
TdReset - Reset the sketch to zero - empty out the sketch and re-initialize it
func (*Client) TopkIncrBy ¶ added in v0.3.0
Increase the score of an item in the data structure by increment.
func (*Client) TopkInfo ¶ added in v0.3.0
Returns number of required items (k), width, depth and decay values.
type MultiHostPool ¶
func NewMultiHostPool ¶
func NewMultiHostPool(hosts []string, authPass *string) *MultiHostPool
func (*MultiHostPool) Close ¶ added in v0.3.0
func (p *MultiHostPool) Close() (err error)
func (*MultiHostPool) Get ¶
func (p *MultiHostPool) Get() redis.Conn
type SingleHostPool ¶
func NewSingleHostPool ¶
func NewSingleHostPool(host string, authPass *string) *SingleHostPool
type TDigestInfo ¶ added in v1.0.0
type TDigestInfo struct {
// contains filtered or unexported fields
}
TDigestInfo is a struct that represents T-Digest properties
func ParseTDigestInfo ¶ added in v1.0.0
func ParseTDigestInfo(result interface{}, err error) (info TDigestInfo, outErr error)
func (*TDigestInfo) Capacity ¶ added in v1.0.0
func (info *TDigestInfo) Capacity() int64
Capacity - returns the capacity of TDigestInfo instance
func (*TDigestInfo) Compression ¶ added in v1.0.0
func (info *TDigestInfo) Compression() int64
Compression - returns the compression of TDigestInfo instance
func (*TDigestInfo) MergedNodes ¶ added in v1.0.0
func (info *TDigestInfo) MergedNodes() int64
MergedNodes - returns the merged nodes of TDigestInfo instance
func (*TDigestInfo) MergedWeight ¶ added in v1.0.0
func (info *TDigestInfo) MergedWeight() float64
MergedWeight - returns the merged weight of TDigestInfo instance
func (*TDigestInfo) TotalCompressions ¶ added in v1.0.0
func (info *TDigestInfo) TotalCompressions() int64
TotalCompressions - returns the total compressions of TDigestInfo instance
func (*TDigestInfo) UnmergedNodes ¶ added in v1.0.0
func (info *TDigestInfo) UnmergedNodes() int64
UnmergedNodes - returns the unmerged nodes of TDigestInfo instance
func (*TDigestInfo) UnmergedWeight ¶ added in v1.0.0
func (info *TDigestInfo) UnmergedWeight() float64
UnmergedWeight - returns the unmerged weight of TDigestInfo instance