"Disclaimer: All rights reserved. Welcome reprint. Do not use for commercial purposes. Contact mailbox: [Email protected] "
1. Background
With the rapid development of the Internet and the advent of the Big Data era. NoSQL database has been developed with its strong scalability, high efficiency and real-time characteristics. Key value (key-value) Storage database is a NoSQL one, the famous Redis is a C development of open-source key value pair storage database.
At the same time there are more and more manufacturers of IoT products, wearable devices, smart home embedded product development ranks, the data of the persistent storage needs have become more and more, selection of a good scalability, the use of small resources, high stability. And can be applied to the embedded products of the persistence of the repository becomes more and more important.
2, Easyflash
Easyflash is an open source lightweight embedded flash memory library that provides a convenient, general-purpose upper-level application interface for MCUs, offering 3 main functions: ENV (environment variable), IAP (online upgrade), and log (Flash storage log). This article mainly describes the ENV function that makes flash a small key-value store database.
3, increase and revise the search
To invoke the frequently used interfaces of environment variables through the console (terminal), the environment variable "TEMP" is shown from creation to save, then change. The last procedure to delete.
These interfaces are supported for direct invocation by the application layer.
Easyflash environment variable function API is located in the https://github.com/armink/easyflash/blob/master/docs/zh/api.md#12-environment variable
The main usages are as follows:
/* 创建Key名为temp的环境变量,并赋初值"123" */ef_set_env("temp","123");/* 改动环境变量temp的值为"456" */ef_set_env("temp","456");/* 读取环境变量temp的值 */char *temp = ef_get_env("temp");/* 删除环境变量temp */ef_set_env("temp","");
4. Usage Scenarios
Now I have applied Easyflash's products. The main storage is the following:
- 1, the product on the implementation of electricity;
- 2, the implementation of records;
- 3, the user can edit the number of references;
- 4, software assertions and hardware anomalies, such as system crash log;
- 5, the online upgrade of the bootloader and the interaction between the app;
- 6, a lot of other storage content to be dug ...
5. Demo
Now the ported hardware platform has stm32f10x and STM32F4XX series on-chip flash and supports bare-metal and rt-thread embedded operating systems. Welcome all Starand pull request. and provide support and advice on many other platforms.
How to apply key value store database in embedded product