在 DB 事务中实现 UNDO

问题描述

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

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 用于撤消,NewValue 用于重做。

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

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)