database-distributedobject-overview.md 2.6 KB
Newer Older
A
annie_wangli 已提交
1 2
# Distributed Data Object Overview

A
Annie_wang 已提交
3
The distributed data object management framework provides object-oriented in-memory data management. It provides basic data management capabilities, such as creating, querying, deleting, and modifying distributed data objects, and observing data and status changes of the distributed data objects. This management framework also provides distributed capabilities to implement data object collaboration for the same application between multiple devices that form a Super Device.
A
annie_wangli 已提交
4 5


A
Annie_wang 已提交
6
## Basic Concepts
A
annie_wangli 已提交
7 8 9

- **Distributed in-memory database**
  
A
Annie_wang 已提交
10
  The distributed in-memory database caches data in the memory so that applications can quickly access data. This database, however, does not store data persistently. If the database is closed, the data is not retained.
A
annie_wangli 已提交
11 12 13 14


- **Distributed data object**

A
Annie_wang 已提交
15
  A distributed data object is an encapsulation of the JS object type. Each distributed data object instance creates a data table in the in-memory database. The in-memory databases created for different applications are isolated from each other. Reading data from and writing data to a distributed data object are mapped to the **put** and **get** operations in the corresponding database, respectively.
A
annie_wangli 已提交
16 17 18

  The distributed data object can be in the following states in its lifecycle:

19 20
  - **Uninitialized**: The distributed data object is not instantiated or has been destroyed.
  - **Local**: The data table is created, but the data cannot be synchronized.
A
Annie_wang 已提交
21
  - **Distributed**: The data table is created, and there are at least two online devices with the same session ID. In this case, data can be synchronized across devices. If a device is offline or the session ID is empty, the distributed data object changes to the local state.
A
annie_wangli 已提交
22 23 24 25


## Working Principles

A
Annie_wang 已提交
26
The distributed data objects are encapsulated into JS objects in distributed in-memory databases. This allows the distributed data objects to be operated in the same way as local variables. The system automatically implements cross-device data synchronization.
A
annie_wangli 已提交
27 28 29 30 31 32 33 34 35 36

**Figure 1** Working mechanism

![how-distributedobject-works](figures/how-distributedobject-works.png)




## Constraints

A
Annie_wang 已提交
37
- Data synchronization can be implemented across devices only for the applications with the same **bundleName**.
A
annie_wangli 已提交
38 39 40 41 42 43 44 45

- Each distributed data object occupies 100 KB to 150 KB of memory. Therefore, you are advised not to create too many distributed data objects.

- The maximum size of a distributed data object is 500 KB.

- For the distributed data object of the complex type, only the root attribute can be modified. The subordinate attributes cannot be modified.
  
- Only JS APIs are supported.