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

Method KVSet

internal/home/client.go:615–635  ·  view source on GitHub ↗
(ctx context.Context, key string, value []byte, opts KVSetOptions)

Source from the content-addressed store, hash-verified

613}
614
615func (c *Client) KVSet(ctx context.Context, key string, value []byte, opts KVSetOptions) (bool, error) {
616 cmd, errClient := c.commandClient()
617 if errClient != nil {
618 return false, errClient
619 }
620 args, errArgs := buildKVSetArgs(key, value, opts)
621 if errArgs != nil {
622 return false, errArgs
623 }
624 result, errSet := cmd.Do(ctx, append([]any{"SET"}, args...)...).Result()
625 if errors.Is(errSet, redis.Nil) {
626 return false, nil
627 }
628 if errSet != nil {
629 return false, errSet
630 }
631 if result == nil {
632 return false, nil
633 }
634 return true, nil
635}
636
637func (c *Client) KVSetNX(ctx context.Context, key string, value []byte, ttl time.Duration) (bool, error) {
638 opts := KVSetOptions{NX: true}

Callers 1

KVSetNXMethod · 0.95

Calls 3

commandClientMethod · 0.95
buildKVSetArgsFunction · 0.85
DoMethod · 0.65

Tested by

no test coverage detected