MCPcopy Create free account
hub / github.com/dbProjectRED/redimo.go / MGET

Method MGET

strings.go:113–144  ·  view source on GitHub ↗

MGET fetches the given keys atomically in a transaction. The call is limited to 25 keys and 4MB. See https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TransactGetItems.html Works similar to https://redis.io/commands/mget

(keys ...string)

Source from the content-addressed store, hash-verified

111//
112// Works similar to https://redis.io/commands/mget
113func (c Client) MGET(keys ...string) (values map[string]ReturnValue, err error) {
114 values = make(map[string]ReturnValue)
115 inputRequests := make([]dynamodb.TransactGetItem, len(keys))
116
117 for i, key := range keys {
118 inputRequests[i] = dynamodb.TransactGetItem{
119 Get: &dynamodb.Get{
120 Key: keyDef{
121 pk: key,
122 sk: emptySK,
123 }.toAV(c),
124 ProjectionExpression: aws.String(strings.Join([]string{vk, c.pk}, ", ")),
125 TableName: aws.String(c.table),
126 },
127 }
128 }
129
130 resp, err := c.ddbClient.TransactGetItemsRequest(&dynamodb.TransactGetItemsInput{
131 TransactItems: inputRequests,
132 }).Send(context.TODO())
133
134 if err != nil {
135 return
136 }
137
138 for _, item := range resp.Responses {
139 pi := parseItem(item.Item, c)
140 values[pi.pk] = pi.val
141 }
142
143 return
144}
145
146// MSET sets the given keys and values atomically in a transaction. The call is limited to 25 keys and 4MB.
147// See https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TransactWriteItems.html

Callers 1

TestAtomicOpsFunction · 0.80

Calls 3

parseItemFunction · 0.85
toAVMethod · 0.45
StringMethod · 0.45

Tested by 1

TestAtomicOpsFunction · 0.64