MCPcopy Index your code
hub / github.com/ByteStorage/FlyDB / ZAdds

Method ZAdds

structure/zset.go:496–516  ·  view source on GitHub ↗

ZAdds adds a value with its given score and member to a sorted set (ZSet), associated with the provided key. It is a method on the ZSetStructure type. Parameters: values: ...ZSetValue multiple values of ZSetValue.

(key string, vals ...ZSetValue)

Source from the content-addressed store, hash-verified

494//
495// values: ...ZSetValue multiple values of ZSetValue.
496func (zs *ZSetStructure) ZAdds(key string, vals ...ZSetValue) error {
497 if err := checkKey(key); err != nil {
498 return err
499 }
500 zSet, err := zs.getOrCreateZSet(key)
501 if err != nil {
502 return fmt.Errorf("failed to get or create ZSet from DB with key '%v': %w", key, err)
503 }
504
505 for _, val := range vals {
506 // if values didn't change, do nothing
507 if zs.valuesDidntChange(zSet, val.score, val.member, val.value) {
508 continue
509 }
510 if err := zs.updateZSet(zSet, key, val.score, val.member, val.value); err != nil {
511 return fmt.Errorf("failed to set ZSet to DB with key '%v': %w", key, err)
512 }
513 }
514
515 return zs.setZSetToDB(stringToBytesWithKey(key), zSet)
516}
517
518// Keys returns all keys of the ZSetStructure.
519//

Callers 1

ZAddMethod · 0.95

Calls 6

getOrCreateZSetMethod · 0.95
valuesDidntChangeMethod · 0.95
updateZSetMethod · 0.95
setZSetToDBMethod · 0.95
checkKeyFunction · 0.85
stringToBytesWithKeyFunction · 0.85

Tested by

no test coverage detected