Hongmeng realizes data persistence through key-value database

Data persistence through key-value database

scene introduction

Key-value databases store data in the form of key-value pairs. When the data to be stored does not have a complex relational model, such as storing commodity names and corresponding prices, employee ID numbers, and whether they have been on duty today, etc., due to the low data complexity, it is easier to be compatible Different database versions and device types, so it is recommended to use a key-value database to persist such data.

constraints

  • For the device coordination database, for each record, the length of Key is ≤896 Byte, and the length of Value is less than 4 MB.
  • For a single-version database, for each record, the length of the Key is ≤1 KB, and the length of the Value is less than 4 MB.
  • Each application supports opening up to 16 key-value distributed databases at the same time.
  • Blocking operations, such as modifying UI components, are not allowed in key-value database event callback methods.

development steps

1. Get a KVManager instance

To use a key-value database, you must first obtain a KVManager instance to manage database objects. The sample code is as follows:

let context = getContext(this) as common

Guess you like

Origin blog.csdn.net/qq_39132095/article/details/132646812