> ## Documentation Index
> Fetch the complete documentation index at: https://botmesh.afaya.com.co/llms.txt
> Use this file to discover all available pages before exploring further.

# MemoryKv

> Class exported by @botmesh/core/spi.

Defined in: [durability/kv.ts:101](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/kv.ts#L101)

In-process [DurableKv](https://botmesh.afaya.com.co/api/core/interfaces/DurableKv.md): the reference implementation.

## Implements

* [`DurableKv`](https://botmesh.afaya.com.co/api/core/interfaces/DurableKv)

## Constructors

### Constructor

```ts theme={null}
new MemoryKv(): MemoryKv;
```

#### Returns

`MemoryKv`

## Methods

### get()

```ts theme={null}
get(table, id): Promise<DurableKvEntry | undefined>;
```

Defined in: [durability/kv.ts:110](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/kv.ts#L110)

#### Parameters

| Parameter | Type |
| - | - |
| `table` | `string` |
| `id` | `string` |

#### Returns

`Promise`\<[`DurableKvEntry`](https://botmesh.afaya.com.co/api/core/spi/interfaces/DurableKvEntry) | `undefined`>

#### Implementation of

[`DurableKv`](https://botmesh.afaya.com.co/api/core/interfaces/DurableKv).[`get`](https://botmesh.afaya.com.co/api/core/interfaces/DurableKv#get)

***

### insert()

```ts theme={null}
insert(
   table, 
   id, 
   value, 
   index
): Promise<string | undefined>;
```

Defined in: [durability/kv.ts:115](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/kv.ts#L115)

#### Parameters

| Parameter | Type |
| - | - |
| `table` | `string` |
| `id` | `string` |
| `value` | `string` |
| `index` | [`DurableKvIndex`](https://botmesh.afaya.com.co/api/core/spi/interfaces/DurableKvIndex) |

#### Returns

`Promise`\<`string` | `undefined`>

#### Implementation of

[`DurableKv`](https://botmesh.afaya.com.co/api/core/interfaces/DurableKv).[`insert`](https://botmesh.afaya.com.co/api/core/interfaces/DurableKv#insert)

***

### replace()

```ts theme={null}
replace(
   table, 
   id, 
   version, 
   value, 
   index
): Promise<string | undefined>;
```

Defined in: [durability/kv.ts:123](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/kv.ts#L123)

#### Parameters

| Parameter | Type |
| - | - |
| `table` | `string` |
| `id` | `string` |
| `version` | `string` |
| `value` | `string` |
| `index` | [`DurableKvIndex`](https://botmesh.afaya.com.co/api/core/spi/interfaces/DurableKvIndex) |

#### Returns

`Promise`\<`string` | `undefined`>

#### Implementation of

[`DurableKv`](https://botmesh.afaya.com.co/api/core/interfaces/DurableKv).[`replace`](https://botmesh.afaya.com.co/api/core/interfaces/DurableKv#replace)

***

### remove()

```ts theme={null}
remove(
   table, 
   id, 
   version
): Promise<boolean>;
```

Defined in: [durability/kv.ts:133](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/kv.ts#L133)

#### Parameters

| Parameter | Type |
| - | - |
| `table` | `string` |
| `id` | `string` |
| `version` | `string` |

#### Returns

`Promise`\<`boolean`>

#### Implementation of

[`DurableKv`](https://botmesh.afaya.com.co/api/core/interfaces/DurableKv).[`remove`](https://botmesh.afaya.com.co/api/core/interfaces/DurableKv#remove)

***

### range()

```ts theme={null}
range(
   table, 
   index, 
   max, 
   limit
): Promise<string[]>;
```

Defined in: [durability/kv.ts:142](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/kv.ts#L142)

#### Parameters

| Parameter | Type |
| - | - |
| `table` | `string` |
| `index` | keyof [`DurableKvIndex`](https://botmesh.afaya.com.co/api/core/spi/interfaces/DurableKvIndex) |
| `max` | `number` |
| `limit` | `number` |

#### Returns

`Promise`\<`string`\[]>

#### Implementation of

[`DurableKv`](https://botmesh.afaya.com.co/api/core/interfaces/DurableKv).[`range`](https://botmesh.afaya.com.co/api/core/interfaces/DurableKv#range)

***

### snapshot()

```ts theme={null}
snapshot(): MemoryKvSnapshot;
```

Defined in: [durability/kv.ts:153](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/kv.ts#L153)

Copy of the whole state.

#### Returns

[`MemoryKvSnapshot`](https://botmesh.afaya.com.co/api/core/spi/interfaces/MemoryKvSnapshot)

***

### restore()

```ts theme={null}
restore(snapshot): void;
```

Defined in: [durability/kv.ts:162](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/kv.ts#L162)

Replace the whole state with `snapshot`.

#### Parameters

| Parameter | Type |
| - | - |
| `snapshot` | [`MemoryKvSnapshot`](https://botmesh.afaya.com.co/api/core/spi/interfaces/MemoryKvSnapshot) |

#### Returns

`void`

#### Throws

on an invalid snapshot.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.