-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(store/redis): use redis SCAN (#97)
* do not fail when redis cannot be initialized Signed-off-by: Jörn Friedrich Dreyer <[email protected]> * make redis store use SCAN to list keys Signed-off-by: Jörn Friedrich Dreyer <[email protected]> * read using scan with prefix and suffix Signed-off-by: Jörn Friedrich Dreyer <[email protected]> * linter does not want to cuddle Signed-off-by: Jörn Friedrich Dreyer <[email protected]> * only run redis unit test when REDIS_URL is configured Signed-off-by: Jörn Friedrich Dreyer <[email protected]> --------- Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
- Loading branch information
Showing
2 changed files
with
125 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,19 +176,12 @@ func Test_rkv_configure_cluster(t *testing.T) { | |
} | ||
|
||
func Test_Store(t *testing.T) { | ||
if tr := os.Getenv("TRAVIS"); len(tr) > 0 { | ||
t.Skip() | ||
url := os.Getenv("REDIS_URL") | ||
if len(url) == 0 { | ||
t.Skip("REDIS_URL not defined") | ||
} | ||
r := new(rkv) | ||
|
||
// r.options = store.Options{Nodes: []string{"redis://:[email protected]:6379"}} | ||
//r.options = store.Options{Nodes: []string{"127.0.0.1:6379"}} | ||
r.options = store.Options{Nodes: []string{"redis://127.0.0.1:6379"}} | ||
|
||
if err := r.configure(); err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
r := NewStore(store.Nodes(url)) | ||
|
||
key := "myTest" | ||
rec := store.Record{ | ||
|
@@ -201,16 +194,30 @@ func Test_Store(t *testing.T) { | |
if err != nil { | ||
t.Errorf("Write Erroe. Error: %v", err) | ||
} | ||
|
||
rec1, err := r.Read(key) | ||
if err != nil { | ||
t.Errorf("Read Error. Error: %v\n", err) | ||
} | ||
|
||
keys, err := r.List() | ||
if err != nil { | ||
t.Errorf("listing error %v\n", err) | ||
} | ||
if len(keys) < 1 { | ||
t.Errorf("not enough keys\n") | ||
} | ||
|
||
err = r.Delete(rec1[0].Key) | ||
if err != nil { | ||
t.Errorf("Delete error %v\n", err) | ||
} | ||
_, err = r.List() | ||
|
||
keys, err = r.List() | ||
if err != nil { | ||
t.Errorf("listing error %v\n", err) | ||
} | ||
if len(keys) > 0 { | ||
t.Errorf("too many keys\n") | ||
} | ||
} |