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

Method LSET

lists.go:655–679  ·  view source on GitHub ↗
(key string, index int64, element string)

Source from the content-addressed store, hash-verified

653}
654
655func (c Client) LSET(key string, index int64, element string) (ok bool, err error) {
656 node, found, err := c.listNodeAtIndex(key, index)
657 if err != nil || !found {
658 return
659 }
660
661 updater := newExpresionBuilder()
662 updater.addConditionExists(c.pk)
663 updater.updateSET(vk, StringValue{element})
664
665 _, err = c.ddbClient.UpdateItemRequest(&dynamodb.UpdateItemInput{
666 ConditionExpression: updater.conditionExpression(),
667 ExpressionAttributeNames: updater.expressionAttributeNames(),
668 ExpressionAttributeValues: updater.expressionAttributeValues(),
669 Key: node.keyAV(c),
670 TableName: aws.String(c.table),
671 UpdateExpression: updater.updateExpression(),
672 }).Send(context.TODO())
673
674 if err != nil {
675 return
676 }
677
678 return true, nil
679}
680
681func (c Client) RPOP(key string) (element ReturnValue, err error) {
682 element, _, err = c.listPop(key, Right)

Callers 1

TestListIndexBasedCRUDFunction · 0.80

Calls 10

listNodeAtIndexMethod · 0.95
newExpresionBuilderFunction · 0.85
addConditionExistsMethod · 0.80
updateSETMethod · 0.80
conditionExpressionMethod · 0.80
updateExpressionMethod · 0.80
keyAVMethod · 0.45
StringMethod · 0.45

Tested by 1

TestListIndexBasedCRUDFunction · 0.64