SetAt writes a key-value pair at the given timestamp.
(key, val []byte, meta byte, ts uint64)
| 76 | |
| 77 | // SetAt writes a key-value pair at the given timestamp. |
| 78 | func (w *TxnWriter) SetAt(key, val []byte, meta byte, ts uint64) error { |
| 79 | return w.update(ts, func(txn *badger.Txn) error { |
| 80 | switch meta { |
| 81 | case BitCompletePosting, BitEmptyPosting: |
| 82 | err := txn.SetEntry((&badger.Entry{ |
| 83 | Key: key, |
| 84 | Value: val, |
| 85 | UserMeta: meta, |
| 86 | }).WithDiscard()) |
| 87 | if err != nil { |
| 88 | return err |
| 89 | } |
| 90 | default: |
| 91 | err := txn.SetEntry(&badger.Entry{ |
| 92 | Key: key, |
| 93 | Value: val, |
| 94 | UserMeta: meta, |
| 95 | }) |
| 96 | if err != nil { |
| 97 | return err |
| 98 | } |
| 99 | } |
| 100 | return nil |
| 101 | }) |
| 102 | } |
| 103 | |
| 104 | // Flush waits until all operations are done and all data is written to disk. |
| 105 | func (w *TxnWriter) Flush() error { |