# Storage

By default, HeadBlocks stores all data locally using SQLite (`plugins/HeadBlocks/headblocks.db`). For multi-server setups, you can use MySQL/MariaDB and Redis.

## MySQL / MariaDB

```yaml
database:
  enable: false
  type: MySQL
  settings:
    hostname: localhost
    database: ''
    username: ''
    password: ''
    port: 3306
    ssl: false
    prefix: ''
    pool:
      maxConnections: 10
      minIdleConnections: 2
      connectionTimeout: 5
      idleTimeout: 300
      maxLifetime: 1800
```

| Option       | Description                                              |
| ------------ | -------------------------------------------------------- |
| **type**     | `MySQL` or `MariaDB`                                     |
| **hostname** | `localhost` or URL to the remote database                |
| **database** | Database name                                            |
| **username** | User with read/write access                              |
| **password** | Password for connection                                  |
| **port**     | Connection port (default: `3306`)                        |
| **ssl**      | Enable SSL requests                                      |
| **prefix**   | Table prefix (e.g., `srv1_`). Use underscore to separate |

### Connection Pool

Advanced settings — most users should not need to change these:

| Option                 | Default | Description                              |
| ---------------------- | ------- | ---------------------------------------- |
| **maxConnections**     | 10      | Maximum connections in the pool          |
| **minIdleConnections** | 2       | Minimum idle connections maintained      |
| **connectionTimeout**  | 5s      | Max time to wait for a connection        |
| **idleTimeout**        | 300s    | Time before an idle connection is closed |
| **maxLifetime**        | 1800s   | Maximum lifetime of a connection         |

{% hint style="warning" %}
Switching from SQLite to MySQL does **not** migrate data automatically. Use `/hb export` to export your data first.
{% endhint %}

## Redis (Multi-Server)

```yaml
redis:
  enable: false
  settings:
    hostname: localhost
    database: 0
    password: ''
    port: 6379
```

Redis enables real-time synchronization across multiple servers:

| Option       | Description                       |
| ------------ | --------------------------------- |
| **hostname** | `localhost` or URL to Redis       |
| **database** | Redis database number (0-15)      |
| **password** | Connection password               |
| **port**     | Connection port (default: `6379`) |

{% hint style="warning" %}
Redis requires a MySQL/MariaDB database connection to work. SQLite alone is not sufficient for multi-server setups.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://aerwyn81.gitbook.io/headblocks/headblocks3/configuration-config.yml/storage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
