Skip to content
This repository has been archived by the owner on Aug 15, 2023. It is now read-only.

数据库 API 改进 #485

Closed
Arondight opened this issue Dec 14, 2021 · 1 comment
Closed

数据库 API 改进 #485

Arondight opened this issue Dec 14, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@Arondight
Copy link
Owner

问题描述

大致有两个改进方向,这两个方向可以同时实现,但是没有意义,因为在思路上它们是互斥的。

多文件存储

为 lowdb 实现一个新的 adapter ,按照目录组织数据库,数据在目录中以多文件进行存储。这样虽然仍然无法避免频繁的文件读写,但是可以避免单次读写大文件带来的低性能。我想小文件频繁读写的性能在非机械盘上应该是可以接受的。

惰性写入

使用 MemorySync adapter 并调度函数定期(如每半小时)同步到文件,程序需要处理 HUP 、 TERM 信号,收到信号时立即写入,写入完毕后退出。运行时数据库 API 只与 MemorySync (实际上是一个 object)交互。调度函数只负责将 MemorySync 的数据定时同步到文件。数据库初始化函数加载文件内容作为初始数据。即对于单个数据库而言整个运行过程只发生一次读取,若干次定时写入。我觉得这样可能会好一点。

#405 停止,需要大量改动代码,同步函数改异步,这个变更是不能承受的。

代码状态:当前提交

d3e6fb1 (HEAD -> dev, origin/master, origin/dev, origin/HEAD, master) update resources

@Arondight Arondight added the enhancement New feature or request label Dec 14, 2021
@Arondight Arondight self-assigned this Dec 14, 2021
@Arondight Arondight mentioned this issue Dec 14, 2021
3 tasks
@Arondight
Copy link
Owner Author

试了一下 Windows 下按照 #140 中的流程不会出现数据丢失问题,直接关闭 Git Bash 会等待数据同步完毕后退出

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant