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

Method listPushActions

lists.go:422–455  ·  view source on GitHub ↗
(key string, element Value, side LSide, flags Flags)

Source from the content-addressed store, hash-verified

420}
421
422func (c Client) listPushActions(key string, element Value, side LSide, flags Flags) (actions []dynamodb.TransactWriteItem, err error) {
423 node := listNode{
424 key: key,
425 value: ReturnValue{element.ToAV()},
426 } // need to set address, left and right.
427
428 currentEndNode, existingList, err := c.listFindEnd(key, side)
429 if err != nil {
430 return
431 }
432
433 if !existingList && flags != nil && flags.has(IfAlreadyExists) {
434 return actions, nil
435 }
436
437 if existingList {
438 node.address = ulid.MustNew(ulid.Now(), rand.Reader).String()
439 node.setNext(side, currentEndNode.address)
440 node.setPrev(side, listNull)
441
442 actions = append(actions, currentEndNode.updateSideAction(side, node.address, c))
443 } else {
444 // start the list with a constant address - this prevents multiple calls from overwriting it
445 node.address = key
446 node.left = listNull
447 node.right = listNull
448 }
449
450 actions = append(actions, node.putAction(c))
451
452 actions = append(actions, c.listCountDeltaAction(key, 1))
453
454 return
455}
456
457func (c Client) listCountDeltaAction(key string, delta int64) dynamodb.TransactWriteItem {
458 return dynamodb.TransactWriteItem{

Callers 2

listPushMethod · 0.95
RPOPLPUSHMethod · 0.95

Calls 9

listFindEndMethod · 0.95
setNextMethod · 0.95
setPrevMethod · 0.95
putActionMethod · 0.95
listCountDeltaActionMethod · 0.95
hasMethod · 0.80
updateSideActionMethod · 0.80
ToAVMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected