记录运行日志:存储产品历史的运行日志,异常告警的记录等
KVDB 键值数据库介绍
- 🌿KVDB 的基础功能的使用:
记录开机次数:
void kvdb\_basic\_sample(fdb\_kvdb\_t kvdb)
{
struct fdb\_blob blob;
int boot_count = 0;
FDB\_INFO("==================== kvdb\_basic\_sample ====================\n");
{ /\* GET the KV value \*/
/\* get the "boot\_count" KV value \*/
fdb\_kv\_get\_blob(kvdb, "boot\_count", fdb\_blob\_make(&blob, &boot_count, sizeof(boot_count)));
/\* the blob.saved.len is more than 0 when get the value successful \*/
if (blob.saved.len > 0) {
FDB\_INFO("get the 'boot\_count' value is %d\n", boot_count);
} else {
FDB\_INFO("get the 'boot\_count' failed\n");
}
}
{ /\* CHANGE the KV value \*/
/\* increase the boot count \*/
boot_count ++;
/\* change the "boot\_count" KV's value \*/
fdb\_kv\_set\_blob(kvdb, "boot\_count", fdb\_blob\_make(&blob, &boot_count, sizeof(boot_count)));
FDB\_INFO("set the 'boot\_count' value to %d\n", boot_count);
}
FDB\_INFO("==================================