Documentation
¶
Index ¶
- 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) 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) TopkAdd(key string, items []string) ([]string, error)
- func (client *Client) TopkCount(key string, items []string) ([]string, 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
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is an interface to time series 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
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) 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) 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