# IKeyValueStorage\<Async>

Defined in: [atomiq-storage-memory-indexed-kv/src/IKeyValueStorage.ts:7](https://github.com/atomiqlabs/atomiq-storage-memory-indexed-kv/blob/e65067d59b4e9456247363a9f25e09e57be9f4c1/src/IKeyValueStorage.ts#L7)

Generic key-value storage interface supporting both synchronous and asynchronous backends. Implement this interface to create custom storage backends for MemoryIndexedKeyValueUnifiedStorage.

## Type Parameters

| Type Parameter              | Description                                                                       |
| --------------------------- | --------------------------------------------------------------------------------- |
| `Async` *extends* `boolean` | When true, all operations return Promises; when false, operations are synchronous |

## Properties

### async

```
async: Async;
```

Defined in: [atomiq-storage-memory-indexed-kv/src/IKeyValueStorage.ts:10](https://github.com/atomiqlabs/atomiq-storage-memory-indexed-kv/blob/e65067d59b4e9456247363a9f25e09e57be9f4c1/src/IKeyValueStorage.ts#L10)

Whether this storage backend is asynchronous

## Methods

### get()

```
get(key): Async extends true ? Promise<string> : string;
```

Defined in: [atomiq-storage-memory-indexed-kv/src/IKeyValueStorage.ts:20](https://github.com/atomiqlabs/atomiq-storage-memory-indexed-kv/blob/e65067d59b4e9456247363a9f25e09e57be9f4c1/src/IKeyValueStorage.ts#L20)

Retrieves a value by key

#### Parameters

| Parameter | Type     | Description        |
| --------- | -------- | ------------------ |
| `key`     | `string` | The key to look up |

#### Returns

`Async` *extends* `true` ? `Promise`<`string`> : `string`

The stored value, or null if not found

***

### getAll()?

```
optional getAll(keys): Async extends true ? Promise<string[]> : string[];
```

Defined in: [atomiq-storage-memory-indexed-kv/src/IKeyValueStorage.ts:46](https://github.com/atomiqlabs/atomiq-storage-memory-indexed-kv/blob/e65067d59b4e9456247363a9f25e09e57be9f4c1/src/IKeyValueStorage.ts#L46)

Retrieves multiple values by keys (optional batch operation)

#### Parameters

| Parameter | Type        | Description              |
| --------- | ----------- | ------------------------ |
| `keys`    | `string`\[] | Array of keys to look up |

#### Returns

`Async` *extends* `true` ? `Promise`<`string`\[]> : `string`\[]

Array of values in the same order as keys, null for missing keys

***

### getKeys()

```
getKeys(): Async extends true ? Promise<string[]> : string[];
```

Defined in: [atomiq-storage-memory-indexed-kv/src/IKeyValueStorage.ts:39](https://github.com/atomiqlabs/atomiq-storage-memory-indexed-kv/blob/e65067d59b4e9456247363a9f25e09e57be9f4c1/src/IKeyValueStorage.ts#L39)

Returns all keys in the storage

#### Returns

`Async` *extends* `true` ? `Promise`<`string`\[]> : `string`\[]

Array of all stored keys

***

### init()

```
init(): Promise<void>;
```

Defined in: [atomiq-storage-memory-indexed-kv/src/IKeyValueStorage.ts:13](https://github.com/atomiqlabs/atomiq-storage-memory-indexed-kv/blob/e65067d59b4e9456247363a9f25e09e57be9f4c1/src/IKeyValueStorage.ts#L13)

Initializes the storage backend

#### Returns

`Promise`<`void`>

***

### remove()

```
remove(key): Async extends true ? Promise<void> : void;
```

Defined in: [atomiq-storage-memory-indexed-kv/src/IKeyValueStorage.ts:33](https://github.com/atomiqlabs/atomiq-storage-memory-indexed-kv/blob/e65067d59b4e9456247363a9f25e09e57be9f4c1/src/IKeyValueStorage.ts#L33)

Removes a value by key

#### Parameters

| Parameter | Type     | Description       |
| --------- | -------- | ----------------- |
| `key`     | `string` | The key to remove |

#### Returns

`Async` *extends* `true` ? `Promise`<`void`> : `void`

***

### removeAll()?

```
optional removeAll(keys): Async extends true ? Promise<void> : void;
```

Defined in: [atomiq-storage-memory-indexed-kv/src/IKeyValueStorage.ts:58](https://github.com/atomiqlabs/atomiq-storage-memory-indexed-kv/blob/e65067d59b4e9456247363a9f25e09e57be9f4c1/src/IKeyValueStorage.ts#L58)

Removes multiple values by keys (optional batch operation)

#### Parameters

| Parameter | Type        | Description             |
| --------- | ----------- | ----------------------- |
| `keys`    | `string`\[] | Array of keys to remove |

#### Returns

`Async` *extends* `true` ? `Promise`<`void`> : `void`

***

### set()

```
set(key, value): Async extends true ? Promise<void> : void;
```

Defined in: [atomiq-storage-memory-indexed-kv/src/IKeyValueStorage.ts:27](https://github.com/atomiqlabs/atomiq-storage-memory-indexed-kv/blob/e65067d59b4e9456247363a9f25e09e57be9f4c1/src/IKeyValueStorage.ts#L27)

Stores a value at the given key

#### Parameters

| Parameter | Type     | Description               |
| --------- | -------- | ------------------------- |
| `key`     | `string` | The key to store under    |
| `value`   | `string` | The string value to store |

#### Returns

`Async` *extends* `true` ? `Promise`<`void`> : `void`

***

### setAll()?

```
optional setAll(values): Async extends true ? Promise<void> : void;
```

Defined in: [atomiq-storage-memory-indexed-kv/src/IKeyValueStorage.ts:52](https://github.com/atomiqlabs/atomiq-storage-memory-indexed-kv/blob/e65067d59b4e9456247363a9f25e09e57be9f4c1/src/IKeyValueStorage.ts#L52)

Stores multiple key-value pairs (optional batch operation)

#### Parameters

| Parameter | Type        | Description                       |
| --------- | ----------- | --------------------------------- |
| `values`  | `object`\[] | Array of key-value pairs to store |

#### Returns

`Async` *extends* `true` ? `Promise`<`void`> : `void`
