Documentation
¶
Overview ¶
Example ¶
package main
import (
"fmt"
redis "github.com/mediocregopher/radix.v2/pool"
"github.com/ride/go-proximity/wrappers/radix"
)
func hErr(err error) {
if err != nil {
panic(err)
}
}
func main() {
client, err := redis.New("tcp", "127.0.0.1:6379", 10)
hErr(err)
wrapper := radix.Wrap(client)
set := NewLocationSet(key, wrapper)
err = set.Add("Toronto", 43.6667, -79.4167)
hErr(err)
err = set.Add("New York", 40.7143, -74.0060)
hErr(err)
results, err := set.Near(43.6687, -79.4167, 500)
hErr(err)
tmp, err := set.Near(43.6687, -79.4167, 500000)
hErr(err)
results = append(results, tmp...)
fmt.Println(results)
client.Cmd("DEL", key)
}
Output: [Toronto Toronto New York]
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultIntervalFinder = intervalsFromRadius
DefaultIntervalFinder gets intervals from Redis given a radius. It will remove neighborhoods that are right next to each other to do less queries.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
ZAdd(set string, score float64, value string) (int64, error)
ZRangeByScore(set string, from float64, to float64) ([]string, error)
}
Client is an for a Redis client.
type Int64arr ¶
type Int64arr []int64
Int64arr is an array of int64 elements that can be sorted using the `sort` package.
func (Int64arr) Include ¶
Include returns if `x` is included in the array `a` or not using binary search.
The array must be sorted before using `Include`
type IntervalFinder ¶
IntervalFinder provides a way to override the way to look for geohashes intervals. Use `proximity.DefaultIntervalFinder` if you don't want to override it.
type LocationSet ¶
type LocationSet struct {
Name string
IntervalFinder IntervalFinder
// contains filtered or unexported fields
}
LocationSet is a set of named points inside a Redis database.
func NewLocationSet ¶
func NewLocationSet(name string, client Client) *LocationSet
NewLocationSet returns a LocationSet