本文整理匯總了Golang中github.com/cockroachdb/cockroach/client.Txn.Get方法的典型用法代碼示例。如果您正苦於以下問題:Golang Txn.Get方法的具體用法?Golang Txn.Get怎麽用?Golang Txn.Get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cockroachdb/cockroach/client.Txn
的用法示例。
在下文中一共展示了Txn.Get方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: readCmd
// readCmd reads a value from the db and stores it in the env.
func readCmd(c *cmd, txn *client.Txn, t *testing.T) *roachpb.Error {
r, pErr := txn.Get(c.getKey())
if pErr != nil {
return pErr
}
if r.Value != nil {
c.env[c.key] = r.ValueInt()
c.debug = fmt.Sprintf("[%d ts=%d]", r.ValueInt(), r.Timestamp())
}
return nil
}
示例2: readCmd
// readCmd reads a value from the db and stores it in the env.
func readCmd(c *cmd, txn *client.Txn, t *testing.T) error {
r, err := txn.Get(c.getKey())
if err != nil {
return err
}
var value int64
if r.Value != nil {
value = r.ValueInt()
}
c.env[c.key] = value
c.debug = fmt.Sprintf("[%d]", value)
return nil
}
示例3: resolveName
// resolveName resolves a table name to a descriptor ID by looking in the
// database. If the mapping is not found, errDescriptorNotFound is returned.
func (m *LeaseManager) resolveName(
txn *client.Txn, dbID sqlbase.ID, tableName string,
) (sqlbase.ID, error) {
nameKey := tableKey{dbID, tableName}
key := nameKey.Key()
gr, err := txn.Get(key)
if err != nil {
return 0, err
}
if !gr.Exists() {
return 0, errDescriptorNotFound
}
return sqlbase.ID(gr.ValueInt()), nil
}