Value retrieves the value of the item from the value log. This method must be called within a transaction. Calling it outside a transaction is considered undefined behavior. If an iterator is being used, then Item.Value() is defined in the current iteration only, because items are reused. If you n
(fn func(val []byte) error)
| 93 | // instead, or copy it yourself. Value might change once discard or commit is called. |
| 94 | // Use ValueCopy if you want to do a Set after Get. |
| 95 | func (item *Item) Value(fn func(val []byte) error) error { |
| 96 | item.wg.Wait() |
| 97 | if item.status == prefetched { |
| 98 | if item.err == nil && fn != nil { |
| 99 | if err := fn(item.val); err != nil { |
| 100 | return err |
| 101 | } |
| 102 | } |
| 103 | return item.err |
| 104 | } |
| 105 | buf, cb, err := item.yieldItemValue() |
| 106 | defer runCallback(cb) |
| 107 | if err != nil { |
| 108 | return err |
| 109 | } |
| 110 | if fn != nil { |
| 111 | return fn(buf) |
| 112 | } |
| 113 | return nil |
| 114 | } |
| 115 | |
| 116 | // ValueCopy returns a copy of the value of the item from the value log, writing it to dst slice. |
| 117 | // If nil is passed, or capacity of dst isn't sufficient, a new slice would be allocated and |
nothing calls this directly
no test coverage detected