本文整理匯總了Golang中github.com/luci/gae/service/datastore.Key.Root方法的典型用法代碼示例。如果您正苦於以下問題:Golang Key.Root方法的具體用法?Golang Key.Root怎麽用?Golang Key.Root使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/luci/gae/service/datastore.Key
的用法示例。
在下文中一共展示了Key.Root方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: writeMutation
// writeMutation ensures that this transaction can support the given key/value
// mutation.
//
// if getOnly is true, don't record the actual mutation data, just ensure that
// the key is in an included entity group (or add an empty entry for that
// group).
//
// if !getOnly && data == nil, this counts as a deletion instead of a Put.
//
// Returns an error if this key causes the transaction to cross too many entity
// groups.
func (td *txnDataStoreData) writeMutation(getOnly bool, key *ds.Key, data ds.PropertyMap) error {
rk := string(keyBytes(key.Root()))
td.Lock()
defer td.Unlock()
if _, ok := td.muts[rk]; !ok {
limit := 1
if td.isXG {
limit = xgEGLimit
}
if len(td.muts)+1 > limit {
msg := "cross-group transaction need to be explicitly specified (xg=True)"
if td.isXG {
msg = "operating on too many entity groups in a single transaction"
}
return errors.New(msg)
}
td.muts[rk] = []txnMutation{}
}
if !getOnly {
td.muts[rk] = append(td.muts[rk], txnMutation{key, data})
}
return nil
}
示例2: testGetMeta
func testGetMeta(c context.Context, k *dsS.Key) int64 {
ds := dsS.Get(c)
mg := &MetaGroup{Parent: k.Root()}
if err := ds.Get(mg); err != nil {
panic(err)
}
return mg.Version
}
示例3: groupIDsKey
func groupIDsKey(key *ds.Key) []byte {
return keyBytes(ds.NewKey("", "", "__entity_group_ids__", "", 1, key.Root()))
}