# Memory management

## Module: [core](https://utca.knowledgator.com/framework-structure#core)

***

***

## <mark style="color:green;">Memory</mark>

Manage data

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**directory**</mark>**&#x20;(Optional\[str], optional):** Path to directory. Defaults to None.
* <mark style="color:orange;">**initial\_data**</mark>**&#x20;(Optional\[Dict\[str, Any]], optional):** Data for initialization of memory. Defaults to None.

***

### <mark style="color:blue;">add\_store</mark>

Save state with the given identifier

#### Arguments:

* <mark style="color:orange;">**identifier**</mark>**&#x20;(str):** Identifier that will be used.
* <mark style="color:orange;">**state**</mark>**&#x20;(Any):** State that will be associated with provided identifier.

***

### <mark style="color:blue;">retrieve\_store</mark>

Retrieve state by its identifier, either from memory or disk

#### Arguments:

* <mark style="color:orange;">**identifier**</mark>**&#x20;(str):** Identifier that will be used.

#### Raises:

* **KeyError:** If identiifier is invalid.

#### Returns:

* **Any:** Data associated with identifier.

***

### <mark style="color:blue;">delete\_store</mark>

Delete a state by its identifier from both memory and disk

#### Arguments:

<mark style="color:orange;">**identifier**</mark>**&#x20;(str):** Identifier to delete.

***

### <mark style="color:blue;">flush</mark>

Clean memory

***

***

***

## <mark style="color:green;">MemorySetInstruction</mark>

Set memory instruction

***

### <mark style="color:blue;">SET</mark>

Set data to memory

***

### <mark style="color:blue;">MOVE</mark>

Set data to memory and remove it from current data

***

***

***

## <mark style="color:green;">SetMemory</mark>

Subclass of [**Component**](https://utca.knowledgator.com/core/component)

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**set\_key**</mark>**&#x20;(str):** Destination key.
* <mark style="color:orange;">**get\_key**</mark>**&#x20;(Optional\[str], optional):** Key that used to retrieve data from register. If equals to None, complete register will be added to memory. Defaults to None.
* <mark style="color:orange;">**memory\_instruction**</mark>**&#x20;(**[**MemorySetInstruction**](#memorysetinstruction)**, optional):** Strategy for memory setting. Defaults to [**MemorySetInstruction**](#memorysetinstruction)**.**[**SET**](#set).

***

### <mark style="color:blue;">\_\_call\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(**[**Transformable**](https://utca.knowledgator.com/schemas#transformable)**):** Current data.
* <mark style="color:orange;">**evaluator**</mark>**&#x20;(Optional\[**[**Evaluator**](https://utca.knowledgator.com/core/evaluator)**], optional):** Evaluator in context of which executed. If equals to None, default evaluator will be created. Defaults to None.

#### Raises:

* **InavalidMemoryInstruction:** If provided instruction doesnt exists.

#### Returns:

* [**Transformable**](https://utca.knowledgator.com/schemas#transformable)**:** Result of execution.

***

***

***

## <mark style="color:green;">MemoryGetInstruction</mark>

Get memory instruction

***

### <mark style="color:blue;">GET</mark>

Get data from memory

***

### <mark style="color:blue;">POP</mark>

Get data from memory and delete it from memory

***

***

***

## <mark style="color:green;">GetMemory</mark>

Subclass of [**Component**](https://utca.knowledgator.com/core/component)

***

### \_\_init\_\_

#### Arguments:

* <mark style="color:orange;">**identifiers**</mark>**&#x20;(List\[Union\[str, Tuple\[str, str]]]):** Key/keys that will be used to access data in memory and for setting to register.
* <mark style="color:orange;">**default**</mark>**&#x20;(Dict\[str, Any]):** A map of values to be returned for each provided identifier if the identifier(s) are not found. If an identifier is not found and no default value is provided for it, an exception will be raised. Defaults to None.
* <mark style="color:orange;">**memory\_instruction**</mark>**&#x20;(**[**MemoryGetInstruction**](#memorygetinstruction)**, optional):** Strategy for memory access. Defaults to [**MemoryGetInstruction**](#memorygetinstruction)**.**[**GET**](#get).

***

### \_\_call\_\_

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(**[**Transformable**](https://utca.knowledgator.com/schemas#transformable)**):** Current data.
* <mark style="color:orange;">**evaluator**</mark>**&#x20;(Optional\[**[**Evaluator**](https://utca.knowledgator.com/core/evaluator)**], optional):** Evaluator in context of which executed. If equals to None, default evaluator will be created. Defaults to None.

#### Raises:

* **InavalidMemoryInstruction:** If provided instruction doesnt exists.

#### Returns:

* [**Transformable**](https://utca.knowledgator.com/schemas#transformable)**:** Result of execution.

***

***

***

## <mark style="color:green;">DeleteMemory</mark>

Delete data from memory

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**identifiers**</mark>**&#x20;(Optional\[List\[str]], optional):** Keys associated with data. If equals to None, flushes memory. Defaults to None.

***

### <mark style="color:blue;">\_\_call\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(**[**Transformable**](https://utca.knowledgator.com/schemas#transformable)**):** Current data.
* <mark style="color:orange;">**evaluator**</mark>**&#x20;(Optional\[**[**Evaluator**](https://utca.knowledgator.com/core/evaluator)**], optional):** Evaluator in context of which executed. If equals to None, default evaluator will be created. Defaults to None.

#### Raises:

* **InavalidMemoryInstruction:** If provided instruction doesnt exists.

#### Returns:

* [**Transformable**](https://utca.knowledgator.com/schemas#transformable)**:** Result of execution.

***

***

***

## <mark style="color:green;">MemoryManager</mark>

Manage memory

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**directory**</mark>**&#x20;(Optional\[str], optional):** Path to directory. Defaults to None.
* <mark style="color:orange;">**initial\_data**</mark>**&#x20;(Optional\[Dict\[str, Any]], optional):** Data for initialization of memory. Defaults to None.

***

### <mark style="color:blue;">get</mark>

Get data from memory

#### Arguments:

* <mark style="color:orange;">**register**</mark>**&#x20;(**[**Transformable**](https://utca.knowledgator.com/schemas#transformable)**):** Current data.
* <mark style="color:orange;">**identifiers**</mark>**&#x20;(List\[Union\[str, Tuple\[str, str]]]):** Key/keys that will be used to access data in memory and for setting to register.
* <mark style="color:orange;">**default**</mark>**&#x20;(Dict\[str, Any]):** A map of values to be returned for each provided identifier if the identifier(s) are not found. If an identifier is not found and no default value is provided for it, an exception will be raised. Defaults to None.
* <mark style="color:orange;">**delete**</mark>**&#x20;(bool, optional):** If equals to True, deletes accessed memory identifiers. Defaults to False.

#### Returns:

* [**Transformable**](https://utca.knowledgator.com/schemas#transformable)**:** Result of execution.

***

### <mark style="color:blue;">set</mark>

Set data to memory

#### Arguments:

* <mark style="color:orange;">**register**</mark>**&#x20;(**[**Transformable**](https://utca.knowledgator.com/schemas#transformable)**):** Current data.
* <mark style="color:orange;">**get\_key**</mark>**&#x20;(str):** Source of data.
* <mark style="color:orange;">**set\_key**</mark>**&#x20;(str):** Destination in memory.

***

### <mark style="color:blue;">delete</mark>

Delete specified identifier from memory

#### Arguments:

* <mark style="color:orange;">**identifier**</mark>**&#x20;(str):** Identifier to delete.

***

### <mark style="color:blue;">flush</mark>

Clean memory

***

***
