forked from mirror/redis
Add Geo commands read-only variants
This commit is contained in:
parent
da63fe7def
commit
cf6c6dca84
20
command.go
20
command.go
|
@ -799,7 +799,9 @@ type GeoRadiusQuery struct {
|
||||||
WithGeoHash bool
|
WithGeoHash bool
|
||||||
Count int
|
Count int
|
||||||
// Can be ASC or DESC. Default is no sort order.
|
// Can be ASC or DESC. Default is no sort order.
|
||||||
Sort string
|
Sort string
|
||||||
|
Store string
|
||||||
|
StoreDist string
|
||||||
}
|
}
|
||||||
|
|
||||||
type GeoLocationCmd struct {
|
type GeoLocationCmd struct {
|
||||||
|
@ -817,20 +819,28 @@ func NewGeoLocationCmd(q *GeoRadiusQuery, args ...interface{}) *GeoLocationCmd {
|
||||||
args = append(args, "km")
|
args = append(args, "km")
|
||||||
}
|
}
|
||||||
if q.WithCoord {
|
if q.WithCoord {
|
||||||
args = append(args, "WITHCOORD")
|
args = append(args, "withcoord")
|
||||||
}
|
}
|
||||||
if q.WithDist {
|
if q.WithDist {
|
||||||
args = append(args, "WITHDIST")
|
args = append(args, "withdist")
|
||||||
}
|
}
|
||||||
if q.WithGeoHash {
|
if q.WithGeoHash {
|
||||||
args = append(args, "WITHHASH")
|
args = append(args, "withhash")
|
||||||
}
|
}
|
||||||
if q.Count > 0 {
|
if q.Count > 0 {
|
||||||
args = append(args, "COUNT", q.Count)
|
args = append(args, "count", q.Count)
|
||||||
}
|
}
|
||||||
if q.Sort != "" {
|
if q.Sort != "" {
|
||||||
args = append(args, q.Sort)
|
args = append(args, q.Sort)
|
||||||
}
|
}
|
||||||
|
if q.Store != "" {
|
||||||
|
args = append(args, "store")
|
||||||
|
args = append(args, q.Store)
|
||||||
|
}
|
||||||
|
if q.StoreDist != "" {
|
||||||
|
args = append(args, "storedist")
|
||||||
|
args = append(args, q.StoreDist)
|
||||||
|
}
|
||||||
return &GeoLocationCmd{
|
return &GeoLocationCmd{
|
||||||
baseCmd: baseCmd{_args: args},
|
baseCmd: baseCmd{_args: args},
|
||||||
q: q,
|
q: q,
|
||||||
|
|
14
commands.go
14
commands.go
|
@ -234,7 +234,9 @@ type Cmdable interface {
|
||||||
GeoAdd(key string, geoLocation ...*GeoLocation) *IntCmd
|
GeoAdd(key string, geoLocation ...*GeoLocation) *IntCmd
|
||||||
GeoPos(key string, members ...string) *GeoPosCmd
|
GeoPos(key string, members ...string) *GeoPosCmd
|
||||||
GeoRadius(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd
|
GeoRadius(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd
|
||||||
|
GeoRadiusRO(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd
|
||||||
GeoRadiusByMember(key, member string, query *GeoRadiusQuery) *GeoLocationCmd
|
GeoRadiusByMember(key, member string, query *GeoRadiusQuery) *GeoLocationCmd
|
||||||
|
GeoRadiusByMemberRO(key, member string, query *GeoRadiusQuery) *GeoLocationCmd
|
||||||
GeoDist(key string, member1, member2, unit string) *FloatCmd
|
GeoDist(key string, member1, member2, unit string) *FloatCmd
|
||||||
GeoHash(key string, members ...string) *StringSliceCmd
|
GeoHash(key string, members ...string) *StringSliceCmd
|
||||||
Command() *CommandsInfoCmd
|
Command() *CommandsInfoCmd
|
||||||
|
@ -2061,12 +2063,24 @@ func (c *cmdable) GeoRadius(key string, longitude, latitude float64, query *GeoR
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *cmdable) GeoRadiusRO(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd {
|
||||||
|
cmd := NewGeoLocationCmd(query, "georadius_ro", key, longitude, latitude)
|
||||||
|
c.process(cmd)
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
func (c *cmdable) GeoRadiusByMember(key, member string, query *GeoRadiusQuery) *GeoLocationCmd {
|
func (c *cmdable) GeoRadiusByMember(key, member string, query *GeoRadiusQuery) *GeoLocationCmd {
|
||||||
cmd := NewGeoLocationCmd(query, "georadiusbymember", key, member)
|
cmd := NewGeoLocationCmd(query, "georadiusbymember", key, member)
|
||||||
c.process(cmd)
|
c.process(cmd)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *cmdable) GeoRadiusByMemberRO(key, member string, query *GeoRadiusQuery) *GeoLocationCmd {
|
||||||
|
cmd := NewGeoLocationCmd(query, "georadiusbymember_ro", key, member)
|
||||||
|
c.process(cmd)
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
func (c *cmdable) GeoDist(key string, member1, member2, unit string) *FloatCmd {
|
func (c *cmdable) GeoDist(key string, member1, member2, unit string) *FloatCmd {
|
||||||
if unit == "" {
|
if unit == "" {
|
||||||
unit = "km"
|
unit = "km"
|
||||||
|
|
Loading…
Reference in New Issue