本文整理汇总了Golang中github.com/tetrafolium/gae/service/datastore.Key.Root方法的典型用法代码示例。如果您正苦于以下问题:Golang Key.Root方法的具体用法?Golang Key.Root怎么用?Golang Key.Root使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tetrafolium/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()))
}