// PutMulti is the batch version of Put
PutMulti is the batch version of Put
// PutMulti is the batch version of Put
func (c *Client) PutMulti(ctx context.Context, keys []*datastore.Key, src interface{}) ([]*datastore.Key, error) {
	keys, err := c.DSClient.PutMulti(ctx, keys, src)
	if err != nil {
		return nil, fmt.Errorf("dscache.Client.PutMulti: failed %v", err)
	}
	vals := reflect.ValueOf(src)
	valMap := make(map[string]interface{})
	var cKeys []string
	for idx, key := range keys {
		cKey := cacheKey(key)
		valMap[cKey] = vals.Index(idx).Interface()
		cKeys = append(cKeys, cKey)
	}
	if err := c.putMultiCache(valMap); err != nil {
		if err2 := c.Cache.Delete(cKeys...); err2 != nil {
			log.Printf("dscache.Client.PutMulti: permanent failure possible stale data for keys: %v err: %v delerr: %v", keys, err, err2)
		}
	}
	return keys, nil
}
func ( c * Client ) PutMulti ( ctx context . Context , keys [ ] * datastore . Key , src interface { } ) ( [ ] * datastore . Key , error ) { keys , err := c . DSClient . PutMulti ( ctx , keys , src ) if err != nil { return nil , fmt . Errorf ( " " , err ) } vals := reflect . ValueOf ( src ) valMap := make ( map [ string ] interface { } ) var cKeys [ ] string for idx , key := range keys { cKey := cacheKey ( key ) valMap [ cKey ] = vals . Index ( idx ) . Interface ( ) cKeys = append ( cKeys , cKey ) } if err := c . putMultiCache ( valMap ) ; err != nil { if err2 := c . Cache . Delete ( cKeys ... ) ; err2 != nil { log . Printf ( " " , keys , err , err2 ) } } return keys , nil }
PutMulti is the batch version of Put
PutMulti is the batch version of Put
// delete on failure to put into cache