- Key Concepts
- Understanding Runtime Data Management
Understanding Runtime Data Management
Purpose
The purpose of this document is to describe how to use the data storage capabilities provided by the mim OE Runtime.
Intended Readers
The intended readers of this document are software developers, system engineers, application architects, deployment and security personnel, and other technical professionals who want to understand the details of Data Management under mim OE.
What You Will Learn from this Document
After reading this document, you will:
- Understand the data storage architecture provided to microservices running under the mim OE Runtime
- Have a working knowledge of some of the use cases that the mim OE Runtime's data storage architecture can satisfy
What You Need to Know Before You Start
In order to get the full benefit from reading this document, you need to have:
- An general understanding of key-value storage
- A general understanding of the mim OE Runtime and how it supports microservices
- A general understanding of microservice development under mim OE
The Essentials of mim OE Data Management
The mim OE Runtime is a serverless environment that provides key-value storage capabilities to a microservice by default. The mechanism for storing and retrieving key-value data is the mim OE Context Object. (You can read about the details of the mim OE Context Object in the Key Concepts section, Understanding the mim OE Context Object).
The Context Object has a property storage,
which is a JavaScript object that has the functions necessary to manage key-value data. Listing 1 below shows the functions that are associated with the storage
property.
1: context2: ├── storage3: │ ├── getItem(key)4: │ ├── setItem(key, value)5: │ ├── eachItem(callback(key, value))6: │ ├── removeItem(key)7: │ ├── saveFile(fileName, base64EncodedString)8: │ └── deleteFile(fileName)
Listing 1: The functions of the context.storage
object.
Developers use the context.storage
functions to set, retrieve and delete key-value data. Also, developers can traverse all the stored key-value pairs in the given mim OE node using the context.storage.forEach()
function.
In addition to storing string and numeric values, the context.storage
object allows developers to store the contents of a file according to filename using the function context.storage.saveFile(fileName, base64EncodedString)
.
The scope of storage in using the Context Object
All data stored by a microservice is local to the particular device on which the mim OE Runtime operates. Sharing data between microservices on various devices requires that developers expose the data stored on a particular mim OE enabled device by way of a microservice endpoint that is custom coded. There is no automatic way to access data. All data access is provided by way of custom-coded microservices.