MCPcopy
hub / github.com/nats-io/nats.go / Put

Method Put

kv.go:677–698  ·  view source on GitHub ↗

Put will place the new value for the key into the store.

(key string, value []byte)

Source from the content-addressed store, hash-verified

675
676// Put will place the new value for the key into the store.
677func (kv *kvs) Put(key string, value []byte) (revision uint64, err error) {
678 if !keyValid(key) {
679 return 0, ErrInvalidKey
680 }
681
682 var b strings.Builder
683 if kv.useJSPfx {
684 b.WriteString(kv.js.opts.pre)
685 }
686 if kv.putPre != _EMPTY_ {
687 b.WriteString(kv.putPre)
688 } else {
689 b.WriteString(kv.pre)
690 }
691 b.WriteString(key)
692
693 pa, err := kv.js.Publish(b.String(), value)
694 if err != nil {
695 return 0, err
696 }
697 return pa.Sequence, err
698}
699
700// PutString will place the string for the key into the store.
701func (kv *kvs) PutString(key string, value string) (revision uint64, err error) {

Callers 1

PutStringMethod · 0.95

Calls 3

keyValidFunction · 0.70
PublishMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected