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

Function GetString

db/string.go:26–43  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

24// otherwise object is null if key is not exist and err is not found
25// otherwise return err
26func 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
46func NewString(txn *Transaction, key []byte) *String {

Callers 15

setValueFunction · 0.85
getValueFunction · 0.85
TestGetStringFunction · 0.85
TestStringGetFunction · 0.85
TestStringSetFunction · 0.85
TestStringLenFunction · 0.85
TestStringExistFunction · 0.85
TestStringAppendFunction · 0.85
TestStringGetSetFunction · 0.85
TestStringGetRangeFunction · 0.85
TestStringSetRangeFunction · 0.85
TestStringIncrFunction · 0.85

Calls 6

decodeMethod · 0.95
NewStringFunction · 0.85
MetaKeyFunction · 0.85
NowFunction · 0.85
IsErrNotFoundFunction · 0.85
GetMethod · 0.80

Tested by 15

setValueFunction · 0.68
getValueFunction · 0.68
TestGetStringFunction · 0.68
TestStringGetFunction · 0.68
TestStringSetFunction · 0.68
TestStringLenFunction · 0.68
TestStringExistFunction · 0.68
TestStringAppendFunction · 0.68
TestStringGetSetFunction · 0.68
TestStringGetRangeFunction · 0.68
TestStringSetRangeFunction · 0.68
TestStringIncrFunction · 0.68