MCPcopy Create free account
hub / github.com/distributedio/titan / MSetNx

Function MSetNx

command/strings.go:159–177  ·  view source on GitHub ↗

MSetNx et multiple keys to multiple values,only if none of the keys exist TODO bug

(ctx *Context, txn *db.Transaction)

Source from the content-addressed store, hash-verified

157// MSetNx et multiple keys to multiple values,only if none of the keys exist
158//TODO bug
159func MSetNx(ctx *Context, txn *db.Transaction) (OnCommit, error) {
160 argc := len(ctx.Args)
161 args := ctx.Args
162 if argc%2 != 0 {
163 return nil, ErrMSet
164 }
165 for i := 2; i <= argc; i += 2 {
166 if str, _ := txn.String([]byte(ctx.Args[0])); !str.Exist() {
167 ctx.Args = append(args[i-2:i], "nx")
168 if _, err := Set(ctx, txn); err != nil {
169 return nil, errors.New("ERR " + err.Error())
170 }
171 ctx.Args = ctx.Args[2:]
172 continue
173 }
174 return Integer(ctx.Out, int64(0)), nil
175 }
176 return Integer(ctx.Out, int64(1)), nil
177}
178
179// Strlen returns the length of the string value stored at key
180func Strlen(ctx *Context, txn *db.Transaction) (OnCommit, error) {

Callers

nothing calls this directly

Calls 5

IntegerFunction · 0.85
SetFunction · 0.70
ExistMethod · 0.65
ErrorMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected