Put will place the new value for the key into the store.
(key string, value []byte)
| 675 | |
| 676 | // Put will place the new value for the key into the store. |
| 677 | func (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. |
| 701 | func (kv *kvs) PutString(key string, value string) (revision uint64, err error) { |