Get the value of key
(ctx *Context, txn *db.Transaction)
| 16 | |
| 17 | // Get the value of key |
| 18 | func 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 |
| 38 | func Set(ctx *Context, txn *db.Transaction) (OnCommit, error) { |
nothing calls this directly
no test coverage detected