XDEL removes the given IDs and returns the IDs that were actually deleted as part of this operation. Note that this operation is not atomic across given IDs – it's possible that an error is returned based on a problem deleting one of the IDs when the others have been deleted. Even when an error is
(key string, ids ...XID)
| 364 | // |
| 365 | // Works similar to https://redis.io/commands/xdel |
| 366 | func (c Client) XDEL(key string, ids ...XID) (deletedItems []XID, err error) { |
| 367 | for _, id := range ids { |
| 368 | resp, err := c.ddbClient.DeleteItemRequest(&dynamodb.DeleteItemInput{ |
| 369 | Key: keyDef{pk: key, sk: id.String()}.toAV(c), |
| 370 | ReturnValues: dynamodb.ReturnValueAllOld, |
| 371 | TableName: aws.String(c.table), |
| 372 | }).Send(context.TODO()) |
| 373 | if err != nil { |
| 374 | return deletedItems, err |
| 375 | } |
| 376 | |
| 377 | if len(resp.Attributes) > 0 { |
| 378 | deletedItems = append(deletedItems, id) |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | return |
| 383 | } |
| 384 | |
| 385 | // XGROUP creates a new group for the stream at the given key. Specifying the start XID |
| 386 | // as XStart will cause consumers of the group to read from the beginning of the stream, |