MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / KVMGet

Method KVMGet

internal/home/client.go:691–720  ·  view source on GitHub ↗
(ctx context.Context, keys ...string)

Source from the content-addressed store, hash-verified

689}
690
691func (c *Client) KVMGet(ctx context.Context, keys ...string) ([][]byte, []bool, error) {
692 if len(keys) == 0 {
693 return nil, nil, nil
694 }
695 cmd, errClient := c.commandClient()
696 if errClient != nil {
697 return nil, nil, errClient
698 }
699 items, errMGet := cmd.MGet(ctx, keys...).Result()
700 if errMGet != nil {
701 return nil, nil, errMGet
702 }
703 values := make([][]byte, len(items))
704 found := make([]bool, len(items))
705 for i, item := range items {
706 switch typed := item.(type) {
707 case nil:
708 continue
709 case string:
710 values[i] = []byte(typed)
711 found[i] = true
712 case []byte:
713 values[i] = append([]byte(nil), typed...)
714 found[i] = true
715 default:
716 return nil, nil, fmt.Errorf("home kv: unsupported MGET item type %T", item)
717 }
718 }
719 return values, found, nil
720}
721
722func (c *Client) KVMSet(ctx context.Context, pairs map[string][]byte) error {
723 if len(pairs) == 0 {

Callers 1

Calls 1

commandClientMethod · 0.95

Tested by 1