Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KV数据库,写满如何处理 #52

Open
joechenchen opened this issue Dec 29, 2020 · 6 comments
Open

KV数据库,写满如何处理 #52

joechenchen opened this issue Dec 29, 2020 · 6 comments

Comments

@joechenchen
Copy link

朱工,你好:
应用中常常需要保存参数到flash中,TS数据库有回滚的配置,但是KV数据库写满后,会返回FDB_SAVED_FULL,用户应该如何操作,是否需要手动调用fdb_kv_set_default清空数据库,然后重新写入?当前,每个flash扇区4K,配置分区起始地址0,大小为8K。

@armink
Copy link
Owner

armink commented Dec 29, 2020

KV 你都用来存什么数据了?

@joechenchen
Copy link
Author

朱工:
static struct fdb_kvdb kvdb = { 0 };
static uint32_t boot_count = 0;
static time_t boot_time[10] = {0, 1, 2, 3};
static uint8_t test[4000] = {0};
static struct fdb_default_kv_node default_kv_table[] = {
{"username", "armink", 0}, /* string KV /
{"password", "123456", 0}, /
string KV /
{"boot_count", &boot_count, sizeof(boot_count)}, /
int type KV /
{"boot_time", &boot_time, sizeof(boot_time)}, /
int array type KV /
{"test", &test, sizeof(test)}, /
测试写满后的操作*/
};

stErr = fdb_kv_set_blob(kvdb, "test", fdb_blob_make(&blob, &test, sizeof(test)));
用来存储系统参数,想验证下写满后,能否继续写入,于是做了个实验,每次存4000个数据,发现第二次调用fdb_kv_set_blob写入4000个数据时,返回FDB_SAVED_FULL,第三次调用fdb_kv_set_blob又能够正常写入,目前将分区大小增大到12K,连续调用10次fdb_kv_set_blob都没出现FDB_SAVED_FULL。我想咨询下KV操作时,当写满时,是否需要用户去执行fdb_kv_set_default操作。

@armink
Copy link
Owner

armink commented Dec 29, 2020

不需要的,fdb_kv_set_default 相当于格式化,用户的数据都被清空了

@joechenchen
Copy link
Author

你好,也就是说KV数据库写满后,能够自动支持重新从起始地址开始,写入最新参数是吧,如果这样的话,就很方便了。

@wwm2021
Copy link

wwm2021 commented Apr 8, 2023

目前的文件结构有点复杂,计划何时规整?

@joechenchen
Copy link
Author

joechenchen commented Apr 8, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants