Skip to main content

# IMemStorage

Get or set values in host application javascript memory. Values stored in memory are not persisted across sessions.

Host application implementing this scripting object ensures there are no collisions with keys from other microapp guest applications. This means two microapps can use the same key to store different values, and their values will not collide.

## Extends​

- `IScriptingObject`

## Methods​

### _dispose()?​

    optional _dispose(): void;

#### Returns​

`void`

#### Inherited from​

`IScriptingObject`.`_dispose`

### _toJSON()​

    _toJSON(): RemotingScriptingObject;

#### Returns​

`RemotingScriptingObject`

#### Inherited from​

`IScriptingObject`.`_toJSON`

### get()​

    get(key: string, isGlobal?: boolean): Promise<unknown>;

Get a value from memory for the given key and microapp id

#### Parameters​

##### key​

`string`

Unique key to retrieve the value

##### isGlobal?​

`boolean`

Optional flag to indicate if the value should be retrieved from global storage across all microapps. Defaults to false

#### Returns​

`Promise`<`unknown`>

Promise resolving to the value stored in memory, or undefined if key doesn't exist

### set()​

    set(
       key: string,
       value: unknown,
    isGlobal?: boolean): Promise<void>;

Set a value in memory for the given key

#### Parameters​

##### key​

`string`

Unique key to store the value

##### value​

`unknown`

Value to be stored. Value should be JSON serializable

##### isGlobal?​

`boolean`

Optional flag to indicate if the value should be stored in global storage accessible across all microapps. Defaults to false

#### Returns​

`Promise`<`void`>

Promise that resolves when the value has been stored

## Properties​

### id​

    readonly id: string;

#### Inherited from​

`IScriptingObject`.`id`

### objectType​

    readonly objectType: string;

#### Inherited from​

`IScriptingObject`.`objectType`