mirror of https://github.com/go-redis/redis.git
Merge pull request #600 from go-redis/fix/geo-ro-variants
Add Geo commands read-only variants
This commit is contained in:
commit
8ca3198da9
20
command.go
20
command.go
|
@ -799,7 +799,9 @@ type GeoRadiusQuery struct {
|
|||
WithGeoHash bool
|
||||
Count int
|
||||
// Can be ASC or DESC. Default is no sort order.
|
||||
Sort string
|
||||
Sort string
|
||||
Store string
|
||||
StoreDist string
|
||||
}
|
||||
|
||||
type GeoLocationCmd struct {
|
||||
|
@ -817,20 +819,28 @@ func NewGeoLocationCmd(q *GeoRadiusQuery, args ...interface{}) *GeoLocationCmd {
|
|||
args = append(args, "km")
|
||||
}
|
||||
if q.WithCoord {
|
||||
args = append(args, "WITHCOORD")
|
||||
args = append(args, "withcoord")
|
||||
}
|
||||
if q.WithDist {
|
||||
args = append(args, "WITHDIST")
|
||||
args = append(args, "withdist")
|
||||
}
|
||||
if q.WithGeoHash {
|
||||
args = append(args, "WITHHASH")
|
||||
args = append(args, "withhash")
|
||||
}
|
||||
if q.Count > 0 {
|
||||
args = append(args, "COUNT", q.Count)
|
||||
args = append(args, "count", q.Count)
|
||||
}
|
||||
if 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{
|
||||
baseCmd: baseCmd{_args: args},
|
||||
q: q,
|
||||
|
|
14
commands.go
14
commands.go
|
@ -234,7 +234,9 @@ type Cmdable interface {
|
|||
GeoAdd(key string, geoLocation ...*GeoLocation) *IntCmd
|
||||
GeoPos(key string, members ...string) *GeoPosCmd
|
||||
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
|
||||
GeoRadiusByMemberRO(key, member string, query *GeoRadiusQuery) *GeoLocationCmd
|
||||
GeoDist(key string, member1, member2, unit string) *FloatCmd
|
||||
GeoHash(key string, members ...string) *StringSliceCmd
|
||||
Command() *CommandsInfoCmd
|
||||
|
@ -2061,12 +2063,24 @@ func (c *cmdable) GeoRadius(key string, longitude, latitude float64, query *GeoR
|
|||
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 {
|
||||
cmd := NewGeoLocationCmd(query, "georadiusbymember", key, member)
|
||||
c.process(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 {
|
||||
if unit == "" {
|
||||
unit = "km"
|
||||
|
|
Loading…
Reference in New Issue