MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / MSet

Method MSet

structure/string.go:452–479  ·  view source on GitHub ↗
(pairs ...interface{})

Source from the content-addressed store, hash-verified

450}
451
452func (s *StringStructure) MSet(pairs ...interface{}) error {
453 if len(pairs)%2 != 0 {
454 return errors.New("Wrong number of arguments")
455 }
456
457 // Create a map to store the key-value pairs
458 data := make(map[string]interface{})
459
460 // Extract key-value pairs from the input arguments and store them in the map
461 for i := 0; i < len(pairs); i += 2 {
462 key, ok := pairs[i].(string)
463 if !ok {
464 return errors.New("Invalid key")
465 }
466
467 value := pairs[i+1]
468 data[key] = value
469 }
470
471 // Set each key-value pair in the map
472 for key, value := range data {
473 if err := s.Set(key, value, 0); err != nil {
474 return err
475 }
476 }
477
478 return nil
479}
480
481// MSetNX sets multiple key-value pairs only if none of the specified keys exist
482func (s *StringStructure) MSetNX(pairs ...interface{}) (bool, error) {

Callers

nothing calls this directly

Calls 1

SetMethod · 0.95

Tested by

no test coverage detected