// Put saves entity into datastore, cache, context cache
Put saves entity into datastore, cache, context cache
// Put saves entity into datastore cache context cache
func (c *Client) Put(ctx context.Context, key *datastore.Key, src interface{}) (*datastore.Key, error) {
	var err error
	key, err = c.DSClient.Put(ctx, key, src)
	if err != nil {
		return nil, fmt.Errorf("dscache.Client.Put: failed error %v", err)
	}
	cKey := cacheKey(key)
	if err := c.putCache(cKey, src); err != nil {
		if err2 := c.Cache.Delete(cKey); err2 != nil {
			log.Printf("dscache.Client.Put: permanent failure possible stale data for key: %v err: %v delerr: %v", key, err, err2)
		}
	}
	return key, nil
}
func ( c * Client ) Put ( ctx context . Context , key * datastore . Key , src interface { } ) ( * datastore . Key , error ) { var err error key , err = c . DSClient . Put ( ctx , key , src ) if err != nil { return nil , fmt . Errorf ( " " , err ) } cKey := cacheKey ( key ) if err := c . putCache ( cKey , src ) ; err != nil { if err2 := c . Cache . Delete ( cKey ) ; err2 != nil { log . Printf ( " " , key , err , err2 ) } } return key , nil }
Put saves entity into datastore, cache, context cache
Put saves entity into datastore cache context cache
// we try to delete on fail to put to avoid stale data