@@ -44,11 +44,11 @@ func NewClientFromPool(pool *redis.Pool, name string) *Client {
4444 return ret
4545}
4646
47- // Reserve - Creates an empty Bloom Filter with a given desired error ratio and initial capacity.
47+ // Reserve - Creates an empty Bloom Filter with a given desired error ratio and initial capacity.
4848// args:
4949// key - the name of the filter
5050// error_rate - the desired probability for false positives
51- // capacity - the number of entries you intend to add to the filter
51+ // capacity - the number of entries you intend to add to the filter
5252func (client * Client ) Reserve (key string , error_rate float64 , capacity uint64 ) (err error ) {
5353 conn := client .Pool .Get ()
5454 defer conn .Close ()
@@ -58,27 +58,27 @@ func (client *Client) Reserve(key string, error_rate float64, capacity uint64) (
5858
5959// Add - Add (or create and add) a new value to the filter
6060// args:
61- // key - the name of the filter
62- // item - the item to add
61+ // key - the name of the filter
62+ // item - the item to add
6363func (client * Client ) Add (key string , item string ) (exists bool , err error ) {
6464 conn := client .Pool .Get ()
6565 defer conn .Close ()
6666 return redis .Bool (conn .Do ("BF.ADD" , key , item ))
6767}
6868
69- // Exists - Determines whether an item may exist in the Bloom Filter or not.
69+ // Exists - Determines whether an item may exist in the Bloom Filter or not.
7070// args:
71- // key - the name of the filter
72- // item - the item to check for
71+ // key - the name of the filter
72+ // item - the item to check for
7373func (client * Client ) Exists (key string , item string ) (exists bool , err error ) {
7474 conn := client .Pool .Get ()
7575 defer conn .Close ()
7676 return redis .Bool (conn .Do ("BF.EXISTS" , key , item ))
7777}
7878
79- // Info - Return information about key
79+ // Info - Return information about key
8080// args:
81- // key - the name of the filter
81+ // key - the name of the filter
8282func (client * Client ) Info (key string ) (info map [string ]int64 , err error ) {
8383 conn := client .Pool .Get ()
8484 defer conn .Close ()
@@ -107,3 +107,27 @@ func (client *Client) Info(key string) (info map[string]int64, err error) {
107107 }
108108 return info , nil
109109}
110+
111+ // BfAddMulti - Adds one or more items to the Bloom Filter, creating the filter if it does not yet exist.
112+ // args:
113+ // key - the name of the filter
114+ // item - One or more items to add
115+ func (client * Client ) BfAddMulti (key string , items []string ) ([]int64 , error ) {
116+ conn := client .Pool .Get ()
117+ defer conn .Close ()
118+ args := redis.Args {key }.AddFlat (items )
119+ result , err := conn .Do ("BF.MADD" , args ... )
120+ return redis .Int64s (result , err )
121+ }
122+
123+ // BfExistsMulti - Determines if one or more items may exist in the filter or not.
124+ // args:
125+ // key - the name of the filter
126+ // item - one or more items to check
127+ func (client * Client ) BfExistsMulti (key string , items []string ) ([]int64 , error ) {
128+ conn := client .Pool .Get ()
129+ defer conn .Close ()
130+ args := redis.Args {key }.AddFlat (items )
131+ result , err := conn .Do ("BF.MEXISTS" , args ... )
132+ return redis .Int64s (result , err )
133+ }
0 commit comments