From 0df21b998a620e68555abe5f0e9bbcc75e3b82dd Mon Sep 17 00:00:00 2001 From: Josh Baker Date: Fri, 21 Oct 2016 08:42:42 -0700 Subject: [PATCH 1/4] updated logo src --- docker/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/README.md b/docker/README.md index 33487c89..11e1062b 100644 --- a/docker/README.md +++ b/docker/README.md @@ -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. From fbff0f4eefc523ba6ea0a9a1d09db4204f6db155 Mon Sep 17 00:00:00 2001 From: Josh Baker Date: Mon, 31 Oct 2016 10:17:30 -0700 Subject: [PATCH 2/4] fix #77 NX/XX bug --- controller/crud.go | 11 ++++++++--- controller/token.go | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/controller/crud.go b/controller/crud.go index aecb7fa9..ecfbbfb6 100644 --- a/controller/crud.go +++ b/controller/crud.go @@ -662,9 +662,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 @@ func (c *Controller) cmdSet(msg *server.Message) (res string, d commandDetailsT, notok: switch msg.OutputType { 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" } diff --git a/controller/token.go b/controller/token.go index f24201fa..37e50356 100644 --- a/controller/token.go +++ b/controller/token.go @@ -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) From d6f83adb306068752bfaf561352df74c9f991210 Mon Sep 17 00:00:00 2001 From: Josh Baker Date: Wed, 2 Nov 2016 09:15:11 -0700 Subject: [PATCH 3/4] match on prefix star, fixes #76w --- controller/glob/glob.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/controller/glob/glob.go b/controller/glob/glob.go index 696214a7..72eb9a7f 100644 --- a/controller/glob/glob.go +++ b/controller/glob/glob.go @@ -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 } From 062da50888ea4656de7f3a82153ef6d7c3889406 Mon Sep 17 00:00:00 2001 From: Josh Baker Date: Wed, 2 Nov 2016 09:15:11 -0700 Subject: [PATCH 4/4] match on prefix star, fixes #76 --- controller/glob/glob.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/controller/glob/glob.go b/controller/glob/glob.go index 696214a7..72eb9a7f 100644 --- a/controller/glob/glob.go +++ b/controller/glob/glob.go @@ -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 }