实验目的:测试每次写入一条以count累加为KEY名的KV。即基本没有GC的空间,写满后它做什么动作。
实验代码如下:
for (count = 1; count < 30000; count++) {
snprintf(key,128,"%010d", count);
snprintf(val,128,"2024-06-07 14:39 %8d", count);
fdb_kv_set(kvdb, key, val);
FDB_INFO("insert [%d]", count);
{ /* GET the KV value */
char *return_value, temp_data2[30] = { 0 };
/* Get the "temp" KV value.
* NOTE: The return value saved in fdb_kv_get's buffer. Please copy away as soon as possible.
*/
return_value = fdb_kv_get(kvdb, key);
/* the return value is NULL when get the value failed */
if (return_value != NULL) {
strncpy(temp_data2, return_value, sizeof(temp_data2));
FDB_INFO("get the value is: %s\n", temp_data2);
}
}
}
为了方便查看,数据库开始地址修改为0x20000,分配4个扇区。
[D/FAL] (fal_flash_init:47) Flash device | stm32_onchip | addr: 0x08000000 | len: 0x00040000 | blk_size: 0x00000800 |initialized finish.
[32;22m[I/FAL] ==================== FAL partition table ====================[0m
[32;22m[I/FAL] | name | flash_dev | offset | length |[0m
[32;22m[I/FAL] -------------------------------------------------------------[0m
[32;22m[I/FAL] | fdb_tsdb1 | stm32_onchip | 0x0001a000 | 0x00002000 |[0m
[32;22m[I/FAL] | fdb_kvdb1 | stm32_onchip | 0x00020000 | 0x00002000 |[0m
[32;22m[I/FAL] ===========