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

Function Append

command/strings.go:200–216  ·  view source on GitHub ↗

Append a value to a key

(ctx *Context, txn *db.Transaction)

Source from the content-addressed store, hash-verified

198
199// Append a value to a key
200func Append(ctx *Context, txn *db.Transaction) (OnCommit, error) {
201 key := []byte(ctx.Args[0])
202 value := []byte(ctx.Args[1])
203 str, err := txn.String(key)
204 if err != nil {
205 if err == db.ErrTypeMismatch {
206 return nil, ErrTypeMismatch
207 }
208 return nil, errors.New("ERR " + err.Error())
209 }
210
211 llen, err := str.Append(value)
212 if err != nil {
213 return nil, errors.New("ERR " + err.Error())
214 }
215 return Integer(ctx.Out, int64(llen)), nil
216}
217
218// GetSet sets the string value of a key and return its old value
219func GetSet(ctx *Context, txn *db.Transaction) (OnCommit, error) {

Callers

nothing calls this directly

Calls 4

IntegerFunction · 0.85
AppendMethod · 0.80
ErrorMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected