Merge branch 'master' into memoptz

This commit is contained in:
Josh Baker 2016-11-14 08:23:06 -07:00
commit fa74d14942
4 changed files with 13 additions and 5 deletions

View File

@ -660,9 +660,9 @@ func (c *Controller) cmdSet(msg *server.Message) (res string, d commandDetailsT,
col = collection.New()
c.setCol(d.key, col)
}
if nx {
if xx || nx {
_, _, ok := col.Get(d.id)
if ok {
if (nx && ok) || (xx && !ok) {
goto notok
}
}
@ -691,7 +691,12 @@ notok:
switch msg.OutputType {
default:
case server.JSON:
res = `{"ok":false,"elapsed":"` + time.Now().Sub(start).String() + "\"}"
if nx {
err = errIDAlreadyExists
} else {
err = errIDNotFound
}
return
case server.RESP:
res = "$-1\r\n"
}

View File

@ -1,5 +1,7 @@
package glob
import "strings"
type Glob struct {
Pattern string
Desc bool
@ -24,7 +26,7 @@ func IsGlob(pattern string) bool {
func Parse(pattern string, desc bool) *Glob {
g := &Glob{Pattern: pattern, Desc: desc, Limits: []string{"", ""}}
if pattern == "*" {
if strings.HasPrefix(pattern, "*") {
g.IsGlob = true
return g
}

View File

@ -15,6 +15,7 @@ const defaultSearchOutput = outputObjects
var errInvalidNumberOfArguments = errors.New("invalid number of arguments")
var errKeyNotFound = errors.New("key not found")
var errIDNotFound = errors.New("id not found")
var errIDAlreadyExists = errors.New("id already exists")
func errInvalidArgument(arg string) error {
return fmt.Errorf("invalid argument '%s'", arg)

View File

@ -1,4 +1,4 @@
![Tile38 Logo](https://github.com/tidwall/tile38/blob/master/doc/logo200.png)
![Tile38 Logo](https://raw.githubusercontent.com/tidwall/tile38/master/doc/logo200.png)
Tile38 is an open source (MIT licensed), in-memory geolocation data store, spatial index, and realtime geofence. It supports a variety of object types including lat/lon points, bounding boxes, XYZ tiles, Geohashes, and GeoJSON.