[**@s4ai/core Documentation v0.3.23**](../../../README.md)

***

[@s4ai/core Documentation](../../../modules.md) / [infrastructure/hybrid-persistence](../README.md) / HybridPersistence

# Class: HybridPersistence

Defined in: infrastructure/hybrid-persistence.js:16

## Constructors

### Constructor

> **new HybridPersistence**(): `HybridPersistence`

Defined in: infrastructure/hybrid-persistence.js:17

#### Returns

`HybridPersistence`

## Properties

### db

> **db**: [`PostgreSQLPersistence`](../../postgresql-persistence/classes/PostgreSQLPersistence.md) \| `null`

Defined in: infrastructure/hybrid-persistence.js:19

***

### initialized

> **initialized**: `boolean`

Defined in: infrastructure/hybrid-persistence.js:20

***

### mode

> **mode**: `string` \| `null`

Defined in: infrastructure/hybrid-persistence.js:18

## Methods

### close()

> **close**(): `Promise`\<`void`\>

Defined in: infrastructure/hybrid-persistence.js:246

Close database connections

#### Returns

`Promise`\<`void`\>

***

### deleteKnowledge()

> **deleteKnowledge**(`key`): `Promise`\<`any`\>

Defined in: infrastructure/hybrid-persistence.js:123

Delete knowledge by key

#### Parameters

##### key

`any`

#### Returns

`Promise`\<`any`\>

***

### getKnowledge()

> **getKnowledge**(`key`): `Promise`\<`any`\>

Defined in: infrastructure/hybrid-persistence.js:64

Get knowledge by key

#### Parameters

##### key

`any`

#### Returns

`Promise`\<`any`\>

***

### getMode()

> **getMode**(): `string` \| `null`

Defined in: infrastructure/hybrid-persistence.js:232

Get current persistence mode

#### Returns

`string` \| `null`

***

### getRecentDecisions()

> **getRecentDecisions**(`limit?`): `Promise`\<`any`\>

Defined in: infrastructure/hybrid-persistence.js:209

Get recent decisions

#### Parameters

##### limit?

`number` = `10`

#### Returns

`Promise`\<`any`\>

***

### initialize()

> **initialize**(): `Promise`\<`string` \| `null`\>

Defined in: infrastructure/hybrid-persistence.js:26

Initialize persistence layer - try PostgreSQL first, fallback to JSON

#### Returns

`Promise`\<`string` \| `null`\>

***

### isPostgreSQLMode()

> **isPostgreSQLMode**(): `boolean`

Defined in: infrastructure/hybrid-persistence.js:239

Check if PostgreSQL is available

#### Returns

`boolean`

***

### listKnowledge()

> **listKnowledge**(): `Promise`\<`any`\>

Defined in: infrastructure/hybrid-persistence.js:145

List all knowledge keys

#### Returns

`Promise`\<`any`\>

***

### saveDecision()

> **saveDecision**(`decision`): `Promise`\<`any`\>

Defined in: infrastructure/hybrid-persistence.js:167

Save autonomous decision

#### Parameters

##### decision

`any`

#### Returns

`Promise`\<`any`\>

***

### setKnowledge()

> **setKnowledge**(`key`, `value`): `Promise`\<`any`\>

Defined in: infrastructure/hybrid-persistence.js:88

Set knowledge by key

#### Parameters

##### key

`any`

##### value

`any`

#### Returns

`Promise`\<`any`\>

***

### updateKnowledge()

> **updateKnowledge**(`key`, `updates`): `Promise`\<`any`\>

Defined in: infrastructure/hybrid-persistence.js:107

Update knowledge (merge with existing)

#### Parameters

##### key

`any`

##### updates

`any`

#### Returns

`Promise`\<`any`\>
