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

Method incr

strings.go:228–247  ·  view source on GitHub ↗
(key string, value Value)

Source from the content-addressed store, hash-verified

226}
227
228func (c Client) incr(key string, value Value) (newValue ReturnValue, err error) {
229 builder := newExpresionBuilder()
230 builder.keys[vk] = struct{}{}
231 resp, err := c.ddbClient.UpdateItemRequest(&dynamodb.UpdateItemInput{
232 ExpressionAttributeNames: builder.expressionAttributeNames(),
233 ExpressionAttributeValues: map[string]dynamodb.AttributeValue{
234 ":delta": value.ToAV(),
235 },
236 Key: keyDef{pk: key, sk: emptySK}.toAV(c),
237 ReturnValues: dynamodb.ReturnValueAllNew,
238 TableName: aws.String(c.table),
239 UpdateExpression: aws.String("ADD #val :delta"),
240 }).Send(context.TODO())
241
242 if err == nil {
243 newValue = ReturnValue{resp.UpdateItemOutput.Attributes[vk]}
244 }
245
246 return
247}
248
249// INCR increments the number stored at the key by 1 (n = n + 1) and returns the new value. If the
250// key does not exist, it will be initialized with zero before applying the operation.

Callers 2

INCRBYFLOATMethod · 0.95
INCRBYMethod · 0.95

Calls 5

newExpresionBuilderFunction · 0.85
ToAVMethod · 0.65
toAVMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected