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

Function MGet

command/strings.go:118–139  ·  view source on GitHub ↗

MGet returns the values of all specified key

(ctx *Context, txn *db.Transaction)

Source from the content-addressed store, hash-verified

116
117// MGet returns the values of all specified key
118func MGet(ctx *Context, txn *db.Transaction) (OnCommit, error) {
119 count := len(ctx.Args)
120 values := make([][]byte, count)
121
122 keys := make([][]byte, count)
123 for i := range ctx.Args {
124 keys[i] = []byte(ctx.Args[i])
125 }
126
127 strs, err := txn.Strings(keys)
128 if err != nil {
129 return nil, errors.New("ERR " + err.Error())
130 }
131 for i, str := range strs {
132 if str == nil || !str.Exist() {
133 values[i] = nil
134 continue
135 }
136 values[i], _ = str.Get()
137 }
138 return BytesArray(ctx.Out, values), nil
139}
140
141// MSet sets the given keys to their respective values
142func MSet(ctx *Context, txn *db.Transaction) (OnCommit, error) {

Callers

nothing calls this directly

Calls 5

BytesArrayFunction · 0.85
StringsMethod · 0.80
GetMethod · 0.80
ErrorMethod · 0.65
ExistMethod · 0.65

Tested by

no test coverage detected