Put will place the new value for the key into the store.
(ctx context.Context, key string, value []byte)
| 1028 | |
| 1029 | // Put will place the new value for the key into the store. |
| 1030 | func (kv *kvs) Put(ctx context.Context, key string, value []byte) (uint64, error) { |
| 1031 | if !keyValid(key) { |
| 1032 | return 0, ErrInvalidKey |
| 1033 | } |
| 1034 | |
| 1035 | var b strings.Builder |
| 1036 | if kv.useJSPfx { |
| 1037 | b.WriteString(kv.js.opts.apiPrefix) |
| 1038 | } |
| 1039 | if kv.putPre != "" { |
| 1040 | b.WriteString(kv.putPre) |
| 1041 | } else { |
| 1042 | b.WriteString(kv.pre) |
| 1043 | } |
| 1044 | b.WriteString(key) |
| 1045 | |
| 1046 | pa, err := kv.js.Publish(ctx, b.String(), value) |
| 1047 | if err != nil { |
| 1048 | return 0, err |
| 1049 | } |
| 1050 | return pa.Sequence, err |
| 1051 | } |
| 1052 | |
| 1053 | // PutString will place the string for the key into the store. |
| 1054 | func (kv *kvs) PutString(ctx context.Context, key string, value string) (uint64, error) { |