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

Function Get

command/strings.go:18–35  ·  view source on GitHub ↗

Get the value of key

(ctx *Context, txn *db.Transaction)

Source from the content-addressed store, hash-verified

16
17// Get the value of key
18func Get(ctx *Context, txn *db.Transaction) (OnCommit, error) {
19 key := ctx.Args[0]
20 str, err := txn.String([]byte(key))
21 if err != nil {
22 if err == db.ErrTypeMismatch {
23 return nil, ErrTypeMismatch
24 }
25 return nil, errors.New("ERR " + err.Error())
26 }
27 val, err := str.Get()
28 if err != nil {
29 if err == db.ErrKeyNotFound {
30 return NullBulkString(ctx.Out), nil
31 }
32 return nil, errors.New("ERR " + err.Error())
33 }
34 return BulkString(ctx.Out, string(val)), nil
35}
36
37// Set key to hold the string value
38func Set(ctx *Context, txn *db.Transaction) (OnCommit, error) {

Callers

nothing calls this directly

Calls 5

NullBulkStringFunction · 0.85
BulkStringFunction · 0.85
GetMethod · 0.80
ErrorMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected