0

我正在实现一个嵌入式键值存储,并希望在其中支持事务。这是我现在一直在研究的模型:

Basic operations supported :
- put(K,V)
- get(K)
- delete(K)

Steps for a put(K,V) :
- Log the K,V into a WAL and flush it to disk.
- Write the actual data on disk. [I do have buffering implemented but 
  we can ignore it for this question].

我读过的所有文献都谈到在日志记录中维护以下状态(在 WAL 中): TxId, OldValue, NewValue其中 OldValue 将用于 Undo,而 NewValue 用于 Redo。

我的问题是如何获得每个键 K 的 OldValue ?如果我需要搜索我的键值存储,即get(K)每个put(K,V)操作,那么这将非常低效,因为我将每次写入与通过存储搜索前一个值联系起来(因为它可能不存在于内存缓存中.)

4

1 回答 1

0

这取决于 okvs 架构的其余部分。如果您使用日志/日志并且不更新磁盘上的表示,并且不支持嵌套事务,则不需要存储旧值。如果您使用 MVCC,您已经拥有旧值。

于 2021-08-15T09:18:58.927 回答