本文整理汇总了Golang中google/golang.org/appengine/datastore.Key.String方法的典型用法代码示例。如果您正苦于以下问题:Golang Key.String方法的具体用法?Golang Key.String怎么用?Golang Key.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类google/golang.org/appengine/datastore.Key
的用法示例。
在下文中一共展示了Key.String方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Set
func (c *Cache) Set(key *datastore.Key, value interface{}) {
if c == nil {
return
}
c.objs[key.String()] = value
}
示例2: Get
func (c *Cache) Get(key *datastore.Key) interface{} {
if c == nil {
return nil
}
return c.objs[key.String()]
}
示例3: lookupCache
func lookupCache(ctx context.Context, key datastore.Key) *MaybeError {
maybeItem, err := memcache.Get(ctx, key.String())
var result = new(MaybeError)
if err != nil { // treat all errors as "cache miss"
*result = CacheMiss{}
} else {
result = jsonToTodoItem(maybeItem.Value)
}
return result
}
示例4: invalidateCache
func invalidateCache(ctx context.Context, key datastore.Key) *MaybeError {
// delete key from memcache
err := memcache.Delete(ctx, key.String())
var result = new(MaybeError)
if err != nil {
*result = E(err.Error())
} else {
*result = Ok{}
}
return result
}
示例5: alertAdmins
func alertAdmins(c context.Context, key *datastore.Key, entity Lockable, reason string) error {
sender := "[email protected]" + appengine.AppID(c) + ".appspot.com"
msg := &mail.Message{
Sender: sender,
Subject: reason,
Body: fmt.Sprintf("key: %s, entity: %#v", key.String(), entity),
}
return mail.SendToAdmins(c, msg)
}
示例6: updateCache
func updateCache(ctx context.Context, key datastore.Key, item TodoItem) {
var result = itemToJson(item)
switch (*result).(type) {
case Blob:
blob := ([]byte)((*result).(Blob))
item := memcache.Item{
Key: key.String(),
Value: blob,
}
memcache.Set(ctx, &item) // ignore errors... worst that can happen is we get a cache miss later
default:
break
}
}
示例7: overwriteLock
// overwrite the current lock
func (l *Locker) overwriteLock(c context.Context, key *datastore.Key, entity Lockable, requestID string) error {
log.Debugf(c, "overwriteLock %s %s", key.String(), requestID)
if l.AlertOnOverwrite {
if err := alertAdmins(c, key, entity, "Lock overwrite"); err != nil {
log.Errorf(c, "failed to send alert email for lock overwrite: %v", err)
}
}
err := storage.RunInTransaction(c, func(tc context.Context) error {
if err := storage.Get(tc, key, entity); err != nil {
return err
}
lock := entity.getLock()
lock.Timestamp = getTime()
lock.RequestID = requestID
if _, err := storage.Put(tc, key, entity); err != nil {
return err
}
return nil
}, nil)
return err
}
示例8: hexKey
// hexKey returns a representation of a key k in base 16.
// Useful for etags.
func hexKey(k *datastore.Key) string {
return fmt.Sprintf("%x", md5.Sum([]byte(k.String())))
}
示例9: Ancestor
func (p *MemcacheQueryPlugin) Ancestor(ancestor *datastore.Key) {
p.buf.WriteString(fmt.Sprintf(":!a=%s", ancestor.String()))
}