Skip to content

Commit

Permalink
Change MSET command to use SDS.
Browse files Browse the repository at this point in the history
Basically use the underlying SET command.
As long as SET is implemented correctly, this should also work.
  • Loading branch information
cnu committed Sep 17, 2015
1 parent 2585395 commit 7cffdef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
24 changes: 12 additions & 12 deletions strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ func (g Godis) MGET(keys ...string) []interface{} {
return output
}

// // MSET sets a slice of key-values
// // pass a slice of keys and value alternating
// // eg: "key1", "value1", "key2", "value2"
// func (g Godis) MSET(items ...string) bool {
// for i, item := range items {
// if i%2 == 1 {
// continue
// }
// g.SET(item, items[i+1])
// }
// return true
// }
// MSET sets a slice of key-values
// pass a slice of keys and value alternating
// eg: "key1", "value1", "key2", "value2"
func (g Godis) MSET(items ...string) bool {
for i, item := range items {
if i%2 == 1 {
continue
}
g.SET(item, items[i+1])
}
return true
}
18 changes: 9 additions & 9 deletions strings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ func TestMGETFewNotExists(t *testing.T) {
}
}

// // Test MSETing key-values pairs into the DB
// func TestMSET(t *testing.T) {
// tests := []string{"key1", "value1", "key2", "value2", "key3", "value3"}
// db := setUp()
// got := db.MSET(tests...)
// if got != true {
// t.Errorf("MSET(%q) == %t, want %t", tests, got, true)
// }
// }
// Test MSETing key-values pairs into the DB
func TestMSET(t *testing.T) {
tests := []string{"key1", "value1", "key2", "value2", "key3", "value3"}
db := setUp()
got := db.MSET(tests...)
if got != true {
t.Errorf("MSET(%q) == %t, want %t", tests, got, true)
}
}

// // Test incrementing values for given key by 1
// func TestINCR(t *testing.T) {
Expand Down

0 comments on commit 7cffdef

Please sign in to comment.