GetString return string object , if key is exist , object load meta otherwise object is null if key is not exist and err is not found otherwise return err
(txn *Transaction, key []byte)
| 24 | // otherwise object is null if key is not exist and err is not found |
| 25 | // otherwise return err |
| 26 | func GetString(txn *Transaction, key []byte) (*String, error) { |
| 27 | str := NewString(txn, key) |
| 28 | mkey := MetaKey(txn.db, key) |
| 29 | now := Now() |
| 30 | Meta, err := txn.t.Get(mkey) |
| 31 | if err != nil { |
| 32 | if IsErrNotFound(err) { |
| 33 | return str, nil |
| 34 | } |
| 35 | return nil, err |
| 36 | } |
| 37 | if err := str.decode(Meta); err != nil && err != ErrKeyNotFound { |
| 38 | return nil, err |
| 39 | } |
| 40 | |
| 41 | str.Meta.UpdatedAt = now |
| 42 | return str, nil |
| 43 | } |
| 44 | |
| 45 | // NewString create new string object |
| 46 | func NewString(txn *Transaction, key []byte) *String { |